Part Number Hot Search : 
BUK9Y MK11G2 1N4623 80025 X1TCG MH66FAD AM29PL AP130
Product Description
Full Text Search
 

To Download PIC16F628T-04SO025 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  1999 microchip technology inc. preliminary ds40300b-page 1 devices included in this data sheet: ? pic16f627 ? pic16f628 referred to collectively as pic16f62x . high performance risc cpu: ? only 35 instructions to learn ? all single-cycle instructions (200 ns), except for program branches which are two-cycle ? operating speed: - dc - 20 mhz clock input - dc - 200 ns instruction cycle ? interrupt capability ? 16 special function hardware registers ? 8-level deep hardware stack ? direct, indirect and relative addressing modes peripheral features: ? 15 i/o pins with individual direction control ? high current sink/source for direct led drive ? analog comparator module with: - two analog comparators - programmable on-chip voltage reference (v ref ) module - programmable input multiplexing from device inputs and internal voltage reference - comparator outputs are externally accessible ? timer0: 8-bit timer/counter with 8-bit programmable prescaler ? timer1: 16-bit timer/counter with external crystal/ clock capability ? timer2: 8-bit timer/counter with 8-bit period regis- ter, prescaler and postscaler ? capture, compare, pwm (ccp) module - capture is 16-bit, max. resolution is 12.5 ns - compare is 16-bit, max. resolution is 200 ns - pwm max. resolution is 10-bit ? universal synchronous/asynchronous receiver/ transmitter usart/sci ? 16 bytes of common ram device memory flash program ram data eeprom data pic16f627 1024 x 14 224 x 8 128 x 8 pic16f628 2048 x 14 224 x 8 128 x 8 special microcontroller features: ? power-on reset (por) ? power-up timer (pwrt) and oscillator start-up timer (ost) ? brown-out detect (bod) ? watchdog timer (wdt) with its own on-chip rc oscillator for reliable operation ? multiplexed mclr -pin ? programmable weak pull-ups on portb ? programmable code protection ? low voltage programming ? power saving sleep mode ? selectable oscillator options - flash configuration bits for oscillator options - er (external resistor) oscillator - reduced part count - dual speed intrc - lower current consumption - ec external clock input - xt oscillator mode - hs oscillator mode - lp oscillator mode ? serial in-circuit programming (via two pins) ? four user programmable id locations cmos technology: ? low-power, high-speed cmos flash technology ? fully static design ? wide operating voltage range - pic16f627 - 3.0v to 5.5v - pic16f628 - 3.0v to 5.5v - pic16lf627 - 2.0v to 5.5v - pic16lf628 - 2.0v to 5.5v ? commercial, industrial and extended temperature range ? low power consumption - < 2.0 ma @ 5.0v, 4.0 mhz -15 m a typical @ 3.0v, 32 khz -< 1.0 m a typical standby current @ 3.0v flash-based 8-bit cmos microcontrollers pic16f62x
pic16f62x ds40300b-page 2 preliminary 1999 microchip technology inc. pin diagrams device differences note 1: if you change from this device to another device, please verify oscillator characteristics in your application. device voltage range oscillator process technology (microns) pic16f627 3.0 - 5.5 see note 1 0.7 pic16f628 3.0 - 5.5 see note 1 0.7 pic16lf627 2.0 - 5.5 see note 1 0.7 pic16lf628 2.0 - 5.5 see note 1 0.7 2 3 4 5 6 7 8 9 10 ?1 2 3 4 5 6 7 8 9 ?1 19 18 16 15 14 13 12 11 17 18 17 15 14 13 12 11 10 16 20 pdip, soic ssop pic16f62x pic16f62x ra6/osc2/clkout ra7/osc1/clkin v ss v ss v dd v dd ra1/an1 ra0/an0 rb6/t1oso/t1cki rb7/t1osi rb1/rx/dt rb2/tx/ck rb3/ccp1 rb4/pgm rb5 ra3/an3/cmp1 ra4/tocki/cmp2 ra5/mclr /thv rb0/int ra2/an2/v ref v ss rb1/rx/dt rb2/tx/ck rb3/ccp1 ra3/an3/cmp1 ra4/tocki/cmp2 ra5/mclr /thv rb0/int ra2/an2/v ref ra6/osc2/clkout ra7/osc1/clkin v dd ra1/an1 ra0/an0 rb6/t1oso/t1cki rb7/t1osi rb4/pgm rb5
1999 microchip technology inc. preliminary ds40300b-page 3 pic16f62x table of contents 1.0 general description......................................................................................................... ............................................................ 5 2.0 pic16f62x device varieties................................................................................................. ..................................................... 7 3.0 architectural overview ...................................................................................................... .......................................................... 9 4.0 memory organization ......................................................................................................... ....................................................... 13 5.0 i/o ports ................................................................................................................... ................................................................. 27 6.0 timer0 module ............................................................................................................... ........................................................... 45 7.0 timer1 module ............................................................................................................... ........................................................... 50 8.0 timer2 module ............................................................................................................... ........................................................... 54 9.0 comparator module........................................................................................................... ........................................................ 57 10.0 capture/compare/pwm (ccp) module ........................................................................................... ......................................... 63 11.0 voltage reference module................................................................................................... ..................................................... 69 12.0 universal synchronous asynchronous receiver transmitter (usart)............................................................ ........................ 71 13.0 data eeprom memory ......................................................................................................... ................................................... 91 14.0 special features of the cpu................................................................................................ ..................................................... 95 15.0 instruction set summary .................................................................................................... ..................................................... 113 16.0 development support........................................................................................................ ...................................................... 125 17.0 electrical specifications.................................................................................................. ......................................................... 131 18.0 device characterization information ........................................................................................ ............................................... 145 19.0 packaging information...................................................................................................... ....................................................... 147 index .......................................................................................................................... ........................................................................ 151 on-line support................................................................................................................ ................................................................. 155 reader response ................................................................................................................ .............................................................. 156 pic16f62x product identification system....................................................................................... ................................................. 157 to our valued customers most current data sheet to obtain the most up-to-date version of this data sheet, please register at our worldwide web site at: http://www.microchip.com you can determine the version of a data sheet by examining its literature number found on the bottom outside corner of any page . the last character of the literature number is the version number. e.g., ds30000a is version a of document ds30000. new customer notification system register on our web site (www.microchip.com/cn) to receive the most current information on our products. errata an errata sheet may exist for current devices, describing minor operational differences (from the data sheet) and recommended workarounds. as device/documentation issues become known to us, we will publish an errata sheet. the errata will specify the re vi- sion of silicon and revision of document to which it applies. to determine if an errata sheet exists for a particular device, please check with one of the following: ? microchips worldwide web site; http://www.microchip.com ? your local microchip sales office (see last page) ? the microchip corporate literature center; u.s. fax: (602) 786-7277 when contacting a sales office or the literature center, please specify which device, revision of silicon and data sheet (inclu de liter- ature number) you are using. corrections to this data sheet we constantly strive to improve the quality of all our products and documentation. we have spent a great deal of time to ensure that this document is correct. however, we realize that we may have missed a few things. if you find any information that is mi ssing or appears in error, please: ? fill out and mail in the reader response form in the back of this data sheet. ? e-mail us at webmaster@microchip.com. we appreciate your assistance in making this a better document.
pic16f62x ds40300b-page 4 preliminary 1999 microchip technology inc. notes:
1999 microchip technology inc. preliminary ds40300b-page 5 pic16f62x 1.0 general description the pic16f62x are 18-pin flash-based members of the versatile pic16cxx family of low-cost, high-performance, cmos, fully-static, 8-bit microcontrollers. all picmicro ? microcontrollers employ an advanced risc architecture. the pic16f62x have enhanced core features, eight-level deep stack, and multiple inter- nal and external interrupt sources. the separate instruction and data buses of the harvard architecture allow a 14-bit wide instruction word with the separate 8-bit wide data. the two-stage instruction pipeline allows all instructions to execute in a single-cycle, except for program branches (which require two cycles). a total of 35 instructions (reduced instruction set) are available. additionally, a large register set gives some of the architectural innovations used to achieve a very high performance. pic16f62x microcontrollers typically achieve a 2:1 code compression and a 4:1 speed improvement over other 8-bit microcontrollers in their class. pic16f62x devices have special features to reduce external components, thus reducing system cost, enhancing system reliability and reducing power con- sumption. there are eight oscillator configurations, of which the single pin er oscillator provides a low-cost solution. the lp oscillator minimizes power consump- tion, xt is a standard crystal, intrc is a self-contained internal oscillator and the hs is for high speed crys- tals. the sleep (power-down) mode offers power sav- ings. the user can wake up the chip from sleep through several external and internal interrupts and reset. a highly reliable watchdog timer with its own on-chip rc oscillator provides protection against software lock- up. table 1-1 shows the features of the pic16f62x mid-range microcontroller families. a simplified block diagram of the pic16f62x is shown in figure 3-1. the pic16f62x series fits in applications ranging from battery chargers to low-power remote sensors. the flash technology makes customization of application programs (detection levels, pulse generation, timers, etc.) extremely fast and convenient. the small footprint packages make this microcontroller series ideal for all applications with space limitations. low-cost, low-power, high-performance, ease of use and i/o flex- ibility make the pic16f62x very versatile. 1.1 development support the pic16f62x family is supported by a full-featured macro assembler, a software simulator, an in-circuit emulator, a low-cost development programmer and a full-featured programmer. a third party c compiler support tool is also available.
pic16f62x ds40300b-page 6 preliminary 1999 microchip technology inc. table 1-1: pic16f62x family of devices pic16f627 pic16f628 pic16lf627 pic16lf628 clock maximum frequency of operation (mhz) 20 20 20 20 memory flash program memory (words) 1024 2048 1024 2048 ram data memory (bytes) 224 224 224 224 eeprom data memory (bytes) 128 128 128 128 peripherals timer module(s) tmr0, tmr1, tmr2 tmr0, tmr1, tmr2 tmr0, tmr1, tmr2 tmr0, tmr1, tmr2 comparators(s) 2 2 2 2 capture/compare/pwm modules 1 1 1 1 serial communications usart usart usart usart internal voltage reference yes yes yes yes features interrupt sources 10 10 10 10 i/o pins 16 16 16 16 voltage range (volts) 3.0-5.5 3.0-5.5 2.0-5.5 2.0-5.5 brown-out detect yes yes yes yes packages 18-pin dip, soic; 20-pin ssop 18-pin dip, soic; 20-pin ssop 18-pin dip, soic; 20-pin ssop 18-pin dip, soic; 20-pin ssop all picmicro ? family devices have power-on reset, selectable watchdog timer, selectable code protect and high i/o current capability. all pic16f62x family devices use serial programming with clock pin rb6 and data pin rb7.
1999 microchip technology inc. preliminary ds40300b-page 7 pic16f62x 2.0 pic16f62x device varieties a variety of frequency ranges and packaging options are available. depending on application and production requirements the proper device option can be selected using the information in the pic16f62x product identification system section at the end of this data sheet. when placing orders, please use this page of the data sheet to specify the correct part number. 2.1 flash devices these devices are offered in the lower cost plastic package, even though the device can be erased and reprogrammed. this allows the same device to be used for prototype development and pilot programs as well as production. a further advantage of the electrically-erasable flash version is that it can be erased and reprogrammed in-circuit, or by device programmers, such as microchip's picstart ? plus or pro mate ? ii programmers. 2.2 quick-turnaround-production (qtp) devices microchip offers a qtp programming service for factory production orders. this service is made available for users who chose not to program a medium to high quantity of units and whose code patterns have stabilized. the devices are standard flash devices but with all program locations and configuration options already programmed by the factory. certain code and prototype verification procedures apply before production shipments are available. please contact your microchip technology sales office for more details. 2.3 serialized quick-turnaround-production (sqtp sm ) devices microchip offers a unique programming service where a few user-defined locations in each device are programmed with different serial numbers. the serial numbers may be random, pseudo-random or sequential. serial programming allows each device to have a unique number which can serve as an entry-code, password or id number.
pic16f62x ds40300b-page 8 preliminary 1999 microchip technology inc. notes:
1999 microchip technology inc. preliminary ds40300b-page 9 pic16f62x 3.0 architectural overview the high performance of the pic16f62x family can be attributed to a number of architectural features commonly found in risc microprocessors. to begin with, the pic16f62x uses a harvard architecture, in which, program and data are accessed from separate memories using separate busses. this improves bandwidth over traditional von neumann architecture where program and data are fetched from the same memory. separating program and data memory further allows instructions to be sized differently than 8-bit wide data word. instruction opcodes are 14-bits wide making it possible to have all single word instructions. a 14-bit wide program memory access bus fetches a 14-bit instruction in a single cycle. a two-stage pipeline over- laps fetch and execution of instructions. consequently, all instructions (35) execute in a single-cycle (200 ns @ 20 mhz) except for program branches. the table below lists program memory (flash, data and eeprom). the pic16f62x can directly or indirectly address its register files or data memory. all special function registers including the program counter are mapped in the data memory. the pic16f62x have an orthogonal (symmetrical) instruction set that makes it possible to carry out any operation on any register using any addressing mode. this symmetrical nature and lack of special optimal situations make programming with the pic16f62x simple yet efficient. in addition, the learning curve is reduced significantly. device memory flash program ram data eeprom data pic16f627 1024 x 14 224 x 8 128 x 8 pic16f628 2048 x 14 224 x 8 128 x 8 pic16lf627 1024 x 14 224 x 8 128 x 8 pic16lf628 2048 x 14 224 x 8 128 x 8 the pic16f62x devices contain an 8-bit alu and working register. the alu is a general purpose arithmetic unit. it performs arithmetic and boolean functions between data in the working register and any register file. the alu is 8-bit wide and capable of addition, subtraction, shift and logical operations. unless otherwise mentioned, arithmetic operations are two's complement in nature. in two-operand instructions, typically one operand is the working register (w register). the other operand is a file register or an immediate constant. in single operand instructions, the operand is either the w register or a file register. the w register is an 8-bit working register used for alu operations. it is not an addressable register. depending on the instruction executed, the alu may affect the values of the carry (c), digit carry (dc), and zero (z) bits in the status register. the c and dc bits operate as a bo rrow and di git bo rrow out bit, respectively, bit in subtraction. see the sublw and subwf instructions for examples. a simplified block diagram is shown in figure 3-1, with a description of the device pins in table 3-1. two types of data memory are provided on the pic16f62x devices. non-volatile eeprom data memory is provided for long term storage of data such as calibration values, look up table data, and any other data which may require periodic updating in the field. this data is not lost when power is removed. the other data memory provided is regular ram data memory. regular ram data memory is provided for temporary storage of data during normal operation. it is lost when power is removed.
pic16f62x ds40300b-page 10 preliminary 1999 microchip technology inc. figure 3-1: block diagram note 1: higher order bits are from the status register. device memory flash program ram data eeprom data pic16f627 1024 x 14 224 x 8 128 x 8 pic16f628 2048 x 14 224 x 8 128 x 8 pic16lf627 1024 x 14 224 x 8 128 x 8 pic16lf628 2048 x 14 224 x 8 128 x 8 flash program memory 13 data bus 8 14 program bus instruction reg program counter 8 level stack (13-bit) ram file registers direct addr 7 ram addr (1) 9 addr mux indirect addr fsr reg status reg mux alu w reg power-up timer oscillator start-up timer power-on reset watchdog timer instruction decode & control timing generation osc1/clkin osc2/clkout mclr v dd , v ss porta portb ra4/t0ck1/cmp2 ra5/mclr /thv rb0/int 8 8 brown-out detect usart ccp1 timer0 timer1 timer2 ra3/an3/cmp1 ra2/an2/v ref ra1/an1 ra0/an0 8 3 data eeprom rb1/rx/dt rb2/tx/ck rb3/ccp1 rb4/pgm rb5 rb6/t1oso/t1cki rb7/t1osi low-voltage programming ra6/osc2/clkout ra7/osc1/clkin v ref comparator
1999 microchip technology inc. preliminary ds40300b-page 11 pic16f62x table 3-1: pic16f62x pinout description name dip/ soic pin # ssop pin # i/o/p type buffer type description ra0/an0 17 19 i/o st bi-directional i/o port/analog comparator input ra1/an1 18 20 i/o st bi-directional i/o port/analog comparator input ra2/an2/v ref 1 1 i/o st bi-directional i/o port/analog comparator input/v ref out- put ra3/an3/cmp1 2 2 i/o st bi-directional i/o port/analog comparator input/compara- tor output ra4/t0cki/cmp2 3 3 i/o st bi-directional i/o port/can be configured as t0cki/com- parator output ra5/mclr /thv 4 4 i st input port/master clear (reset input/programming voltage input. when configured as mclr , this pin is an active low reset to the device. voltage on mclr /thv must not exceed v dd during normal device operation. ra6/osc2/clkout 15 17 i/o st bi-directional i/o port/oscillator crystal output. connects to crystal or resonator in crystal oscillator mode. in er mode, osc2 pin outputs clkout which has 1/4 the fre- quency of osc1, and denotes the instruction cycle rate. ra7/osc1/clkin 16 18 i/o st bi-directional i/o port/oscillator crystal input/external clock source input. er biasing pin. rb0/int 6 7 i/o ttl/st (1) bi-directional i/o port/external interrupt. can be software programmed for internal weak pull-up. rb1/rx/dt 7 8 i/o ttl/st (3) bi-directional i/o port/ usart receive pin/synchronous data i/o. can be software programmed for internal weak pull-up. rb2/tx/ck 8 9 i/o ttl/st (3) bi-directional i/o port/ usart transmit pin/synchronous clock i/o. can be software programmed for internal weak pull-up. rb3/ccp1 9 10 i/o ttl/st (4) bi-directional i/o port/capture/compare/pwm i/o. can be software programmed for internal weak pull-up. rb4/pgm 10 11 i/o ttl/st (5) bi-directional i/o port/low voltage programming input pin. wake-up from sleep on pin change. can be software programmed for internal weak pull-up. when low voltage programming is enabled, the interrupt on pin change and weak pull-up resistor are disabled. rb5 11 12 i/o ttl bi-directional i/o port/wake-up from sleep on pin change. can be software programmed for internal weak pull-up. rb6/t1oso/t1cki 12 13 i/o ttl/st (2) bi-directional i/o port/timer1 oscillator output/timer1 clock input. wake up from sleep on pin change. can be software programmed for internal weak pull-up. rb7/t1osi 13 14 i/o ttl/st (2) bi-directional i/o port/timer1 oscillator input. wake up from sleep on pin change. can be software programmed for internal weak pull-up. v ss 55,6 p ground reference for logic and i/o pins. v dd 14 15,16 p positive supply for logic and i/o pins. legend: o = output i/o = input/output p = power = not used i = input st = schmitt trigger input ttl = ttl input i/od =input/open drain output note 1: this buffer is a schmitt trigger input when configured as the external interrupt. note 2: this buffer is a schmitt trigger input when used in serial programming mode. note 3: this buffer is a schmitt trigger i/o when used in usart/synchronous mode. note 4: this buffer is a schmitt trigger i/o when used in ccp mode. note 5: this buffer is a schmitt trigger input when used in low voltage program mode.
pic16f62x ds40300b-page 12 preliminary 1999 microchip technology inc. 3.1 clocking scheme/instruction cycle the clock input (osc1/clkin/ra7 pin) is internally divided by four to generate four non-overlapping quadrature clocks namely q1, q2, q3 and q4. inter- nally, the program counter (pc) is incremented every q1, the instruction is fetched from the program memory and latched into the instruction register in q4. the instruction is decoded and executed during the following q1 through q4. the clocks and instruction execution flow is shown in figure 3-2. 3.2 instruction flow/pipelining an instruction cycle consists of four q cycles (q1, q2, q3 and q4). the instruction fetch and execute are pipelined such that fetch takes one instruction cycle while decode and execute takes another instruction cycle. however, due to the pipelining, each instruction effectively executes in one cycle. if an instruction causes the program counter to change (e.g., goto ) then two cycles are required to complete the instruction (example 3-1). a fetch cycle begins with the program counter (pc) incrementing in q1. in the execution cycle, the fetched instruction is latched into the instruction register (ir) in cycle q1. this instruction is then decoded and executed during the q2, q3, and q4 cycles. data memory is read during q2 (operand read) and written during q4 (destination write). figure 3-2: clock/instruction cycle example 3-1: instruction pipeline flow q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 osc1 q1 q2 q3 q4 pc osc2/clkout (er mode) pc pc+1 pc+2 fetch inst (pc) execute inst (pc-1) fetch inst (pc+1) execute inst (pc) fetch inst (pc+2) execute inst (pc+1) internal phase clock all instructions are single cycle, except for any program branches. these take two cycles since the fetch instruction is flushed from the pipeline while the new instruction is being fetched and then executed. 1. movlw 55h fetch 1 execute 1 2. movwf portb fetch 2 execute 2 3. call sub_1 fetch 3 execute 3 4. bsf porta, bit3 fetch 4 flush fetch sub_1 execute sub_1
1999 microchip technology inc. preliminary ds40300b-page 13 pic16f62x 4.0 memory organization 4.1 program memory organization the pic16f62x has a 13-bit program counter capable of addressing an 8k x 14 program memory space. only the first 1k x 14 (0000h - 03ffh) for the pic16f627 and 2k x 14 (0000h - 07ffh) for the pic16f628 are physically implemented. accessing a location above these boundaries will cause a wrap-around within the first 1k x 14 space (pic16f627) or 2k x 14 space (pic16f628). the reset vector is at 0000h and the interrupt vector is at 0004h (figure 4-1 and figure 4-2). figure 4-1: program memory map and stack for the pic16f627 pc<12:0> 13 000h 0004 0005 03ffh 0400h 1fffh stack level 1 stack level 8 reset vector interrupt vector on-chip program memory call, return retfie, retlw stack level 2 figure 4-2: program memory map and stack for the pic16f628 4.2 data memory organization the data memory (figure 4-3) is partitioned into four banks which contain the general purpose registers and the special function registers. the special function registers are located in the first 32 locations of each bank. register locations 20-7fh, a0h-ffh, 120h-14fh, 170h-17fh and 1f0h-1ffh are general purpose regis- ters implemented as static ram. the table below lists how to access the four banks of registers: addresses f0h-ffh, 170h-17fh and 1f0h-1ffh are implemented as common ram and mapped back to addresses 70h-7fh. 4.2.1 general purpose register file the register file is organized as 224 x 8 in the pic16f62x. each is accessed either directly or indi- rectly through the file select register fsr (section 4.4). rp1 rp0 bank0 0 0 bank1 0 1 bank2 1 0 bank3 1 1 pc<12:0> 13 000h 0004 0005 07ffh 0800h 1fffh stack level 1 stack level 8 reset vector interrupt vector on-chip program memory call, return retfie, retlw stack level 2
pic16f62x ds40300b-page 14 preliminary 1999 microchip technology inc. figure 4-3: data memory map of the pic16f627 and pic16f628 indirect addr.(*) tmr0 pcl status fsr porta portb pclath intcon pir1 tmr1l tmr1h t1con tmr2 t2con ccpr1l ccpr1h ccp1con option pcl status fsr trisa trisb pclath intcon pie1 pcon pr2 00h 01h 02h 03h 04h 05h 06h 07h 08h 09h 0ah 0bh 0ch 0dh 0eh 0fh 10h 11h 12h 13h 14h 15h 16h 17h 18h 19h 1ah 1bh 1ch 1dh 1eh 1fh 80h 81h 82h 83h 84h 85h 86h 87h 88h 89h 8ah 8bh 8ch 8dh 8eh 8fh 90h 91h 92h 93h 94h 95h 96h 97h 98h 99h 9ah 9bh 9ch 9dh 9eh 9fh 20h a0h 7fh ffh bank 0 bank 1 unimplemented data memory locations, read as '0'. * not a physical register. file address indirect addr.(*) indirect addr.(*) pcl status fsr pclath intcon pcl status fsr pclath intcon 100h 101h 102h 103h 104h 105h 106h 107h 108h 109h 10ah 10bh 10ch 10dh 10eh 10fh 180h 181h 182h 183h 184h 185h 186h 187h 188h 189h 18ah 18bh 18ch 18dh 18eh 18fh 17fh 1ffh bank 2 bank 3 indirect addr.(*) tmr0 option rcsta txreg rcreg cmcon txsta spbrg vrcon general purpose register 1efh 1f0h accesses 70h - 7fh efh f0h accesses 70h-7fh 16fh 170h accesses 70h-7fh trisb portb 96 bytes eedata eeadr eecon1 eecon2* general purpose register 80 bytes general purpose register 48 bytes 11fh 120h 14fh 150h
1999 microchip technology inc. preliminary ds40300b-page 15 pic16f62x 4.2.2 special function registers the special function registers are registers used by the cpu and peripheral functions for controlling the desired operation of the device (table 4-1). these registers are static ram. the special registers can be classified into two sets (core and peripheral). the special function registers associated with the core functions are described in this section. those related to the operation of the peripheral features are described in the section of that peripheral feature. table 4-1: special registers summary bank0 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por reset value on all other resets (1) bank 0 00h indf addressing this location uses contents of fsr to address data memory (not a physical register) xxxx xxxx xxxx xxxx 01h tmr0 timer0 modules register xxxx xxxx uuuu uuuu 02h pcl program counter's (pc) least significant byte 0000 0000 0000 0000 03h status irp rp1 rp0 to pd zdcc 0001 1xxx 000q quuu 04h fsr indirect data memory address pointer xxxx xxxx uuuu uuuu 05h porta ra7 ra6 ra5 ra4 ra3 ra2 ra1 ra0 xxxx 0000 xxxx 0000 06h portb rb7 rb6 rb5 rb4 rb3 rb2 rb1 rb0 xxxx xxxx uuuu uuuu 07h unimplemented 08h unimplemented 09h unimplemented 0ah pclath write buffer for upper 5 bits of program counter ---0 0000 ---0 0000 0bh intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000u 0ch pir1 eeif cmif rcif txif ccp1if tmr2if tmr1if 0000 -000 0000 -000 0dh unimplemented 0eh tmr1l holding register for the least significant byte of the 16-bit tmr1 xxxx xxxx uuuu uuuu 0fh tmr1h holding register for the most significant byte of the 16-bit tmr1 xxxx xxxx uuuu uuuu 10h t1con t1ckps1 t1ckps0 t1oscen t1sync tmr1cs tmr1on --00 0000 --uu uuuu 11h tmr2 tmr2 modules register 0000 0000 0000 0000 12h t2con toutps3 toutps2 toutps1 toutps0 tmr2on t2ckps1 t2ckps0 -000 0000 -uuu uuuu 13h unimplemented 14h unimplemented 15h ccpr1l capture/compare/pwm register (lsb) xxxx xxxx uuuu uuuu 16h ccpr1h capture/compare/pwm register (msb) xxxx xxxx uuuu uuuu 17h ccp1con ccp1x ccp1y ccp1m3 ccp1m2 ccp1m1 ccp1m0 --00 0000 --00 0000 18h rcsta spen rx9 sren cren aden ferr oerr rx9d 0000 -00x 0000 -00x 19h txreg usart transmit data register 0000 0000 0000 0000 1ah rcreg usart receive data register 0000 0000 0000 0000 1bh unimplemented 1ch unimplemented 1dh unimplemented 1eh unimplemented 1fh cmcon c2out c1out c2inv c1inv cis cm2 cm1 cm0 0000 0000 0000 0000 legend: = unimplemented locations read as 0, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented note 1: other (non power-up) resets include mclr reset, brown-out detect and watchdog timer reset during normal operation.
pic16f62x ds40300b-page 16 preliminary 1999 microchip technology inc. table 4-2: special function registers summary bank1 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por reset value on all other resets (1) bank 1 80h indf addressing this location uses contents of fsr to address data memory (not a physical reg- ister) xxxx xxxx xxxx xxxx 81h option rbpu intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 1111 1111 82h pcl program counter's (pc) least significant byte 0000 0000 0000 0000 83h status irp rp1 rp0 to pd zdcc 0001 1xxx 000q quuu 84h fsr indirect data memory address pointer xxxx xxxx uuuu uuuu 85h trisa trisa7 trisa6 trisa4 trisa3 trisa2 trisa1 trisa0 11-1 1111 11-1 1111 86h trisb trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 1111 1111 1111 1111 87h unimplemented 88h unimplemented 89h unimplemented 8ah pclath write buffer for upper 5 bits of program counter ---0 0000 ---0 0000 8bh intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000u 8ch pie1 eeie cmie rcie txie ccp1ie tmr2ie tmr1ie 0000 -000 0000 -000 8dh unimplemented 8eh pcon oscf por bod ---- 1-0x ---- 1-uq 8fh unimplemented 90h unimplemented 91h unimplemented 92h pr2 timer2 period register 11111111 11111111 93h unimplemented 94h unimplemented 95h unimplemented 96h unimplemented 97h unimplemented 98h txsta csrc tx9 txen sync brgh trmt tx9d 0000 -010 0000 -010 99h spbrg baud rate generator register 0000 0000 0000 0000 9ah eedata eeprom data register xxxx xxxx uuuu uuuu 9bh eeadr eeprom address register xxxx xxxx uuuu uuuu 9ch eecon1 wrerr wren wr rd ---- x000 ---- q000 9dh eecon2 eeprom control register 2 (not a physical register) -------- -------- 9eh unimplemented 9fh vrcon vren vroe vrr vr3 vr2 vr1 vr0 000- 0000 000- 0000 legend: : = unimplemented locations read as 0, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented note 1: other (non power-up) resets include mclr reset, brown-out detect and watchdog timer reset during normal operation.
1999 microchip technology inc. preliminary ds40300b-page 17 pic16f62x table 4-3: special function registers summary bank2 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por reset value on all other resets (1) bank 1 100h indf addressing this location uses contents of fsr to address data memory (not a physical reg- ister) xxxx xxxx xxxx xxxx 101h tmr0 rbpu intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 1111 1111 102h pcl program counter's (pc) least significant byte 0000 0000 0000 0000 103h status irp rp1 rp0 to pd zdcc 0001 1xxx 000q quuu 104h fsr indirect data memory address pointer xxxx xxxx uuuu uuuu 105h unimplemented 106h portb trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 1111 1111 1111 1111 107h unimplemented 108h unimplemented 109h unimplemented 10ah pclath write buffer for upper 5 bits of program counter ---0 0000 ---0 0000 10bh intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000u 10ch 10dh unimplemented 10eh 10fh unimplemented 110h unimplemented 111h unimplemented 112h 113h unimplemented 114h unimplemented 115h unimplemented 116h unimplemented 117h unimplemented 118h 119h 11ah 11bh 11ch 11dh 11eh unimplemented 11fh legend: = unimplemented locations read as 0, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented note 1: other (non power-up) resets include mclr reset, brown-out detect and watchdog timer reset during normal operation.
pic16f62x ds40300b-page 18 preliminary 1999 microchip technology inc. table 4-4: special function registers summary bank3 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por reset value on all other resets (1) bank 1 180h indf addressing this location uses contents of fsr to address data memory (not a physical reg- ister) xxxx xxxx xxxx xxxx 181h option rbpu intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 1111 1111 182h pcl program counter's (pc) least significant byte 0000 0000 0000 0000 183h status irp rp1 rp0 to pd zdcc 0001 1xxx 000q quuu 184h fsr indirect data memory address pointer xxxx xxxx uuuu uuuu 185h unimplemented 186h trisb trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 1111 1111 1111 1111 187h unimplemented 188h unimplemented 189h unimplemented 18ah pclath write buffer for upper 5 bits of program counter ---0 0000 ---0 0000 18bh intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000u 18ch 18dh 18eh 18fh 190h 191h 192h 193h 194h 195h 196h 197h 198h 199h 19ah 19bh 19ch 19dh 19eh 19fh legend: = unimplemented locations read as 0, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented note 1: other (non power-up) resets include mclr reset, brown-out detect and watchdog timer reset during normal operation.
1999 microchip technology inc. preliminary ds40300b-page 19 pic16f62x 4.2.2.1 status register the status register, shown in register 4-1, contains the arithmetic status of the alu, the reset status and the bank select bits for data memory (sram). the status register can be the destination for any instruction, like any other register. if the status register is the destination for an instruction that affects the z, dc or c bits, then the write to these three bits is disabled. these bits are set or cleared according to the device logic. furthermore, the to and pd bits are not writable. therefore, the result of an instruction with the status register as destination may be different than intended. for example, clrf status will clear the upper-three bits and set the z bit. this leaves the status register as 000uu1uu (where u = unchanged). it is recommended, therefore, that only bcf, bsf, swapf and movwf instructions are used to alter the status register because these instructions do not affect any status bit. for other instructions, not affecting any status bits, see the instruction set summary. note 1: the c and dc bits operate as a borrow and digit borrow out bit, respectively, in subtraction. see the sublw and subwf instructions for examples. register 4-1: status register (address 03h or 83h) r/w-0 r/w-0 r/w-0 r-1 r-1 r/w-x r/w-x r/w-x irp rp1 rp0 to pd z dc c r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por reset -x = unknown at por reset bit7 bit0 bit 7: irp : register bank select bit (used for indirect addressing) 1 = bank 2, 3 (100h - 1ffh) 0 = bank 0, 1 (00h - ffh) bit 6-5: rp1:rp0 : register bank select bits (used for direct addressing) 11 = bank 3 (180h - 1ffh) 10 = bank 2 (100h - 17fh) 01 = bank 1 (80h - ffh) 00 = bank 0 (00h - 7fh) bit 4: to : time-out bit 1 = after power-up, clrwdt instruction, or sleep instruction 0 = a wdt time-out occurred bit 3: pd : power-down bit 1 = after power-up or by the clrwdt instruction 0 = by execution of the sleep instruction bit 2: z : zero bit 1 = the result of an arithmetic or logic operation is zero 0 = the result of an arithmetic or logic operation is not zero bit 1: dc : digit carry/borrow bit ( addwf , addlw,sublw,subwf instructions)(for borrow the polarity is reversed) 1 = a carry-out from the 4th low order bit of the result occurred 0 = no carry-out from the 4th low order bit of the result bit 0: c : carry/borrow bit ( addwf , addlw,sublw,subwf instructions) 1 = a carry-out from the most significant bit of the result occurred 0 = no carry-out from the most significant bit of the result occurred note: for borrow the polarity is reversed. a subtraction is executed by adding the twos complement of the second operand. for rotate ( rrf , rlf ) instructions, this bit is loaded with either the high or low order bit of the source register.
pic16f62x ds40300b-page 20 preliminary 1999 microchip technology inc. 4.2.2.2 option register the option register is a readable and writable register which contains various control bits to configure the tmr0/wdt prescaler, the external rb0/int interrupt, tmr0, and the weak pull-ups on portb. note: to achieve a 1:1 prescaler assignment for tmr0, assign the prescaler to the wdt (psa = 1). see section 6.3.1 register 4-2: option register (address 81h) r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 rbpu intedg t0cs t0se psa ps2 ps1 ps0 r = readable bit w = writable bit -n = value at por reset bit7 bit0 bit 7: rbpu : portb pull-up enable bit 1 = portb pull-ups are disabled 0 = portb pull-ups are enabled by individual port latch values bit 6: intedg : interrupt edge select bit 1 = interrupt on rising edge of rb0/int pin 0 = interrupt on falling edge of rb0/int pin bit 5: t0cs : tmr0 clock source select bit 1 = transition on ra4/t0cki pin 0 = internal instruction cycle clock (clkout) bit 4: t0se : tmr0 source edge select bit 1 = increment on high-to-low transition on ra4/t0cki pin 0 = increment on low-to-high transition on ra4/t0cki pin bit 3: psa : prescaler assignment bit 1 = prescaler is assigned to the wdt 0 = prescaler is assigned to the timer0 module bit 2-0: ps2:ps0 : prescaler rate select bits 000 001 010 011 100 101 110 111 1 : 2 1 : 4 1 : 8 1 : 16 1 : 32 1 : 64 1 : 128 1 : 256 1 : 1 1 : 2 1 : 4 1 : 8 1 : 16 1 : 32 1 : 64 1 : 128 bit value tmr0 rate wdt rate
1999 microchip technology inc. preliminary ds40300b-page 21 pic16f62x 4.2.2.3 intcon register the intcon register is a readable and writable register which contains the various enable and flag bits for all interrupt sources except the comparator module. see section 4.2.2.4 and section 4.2.2.5 for a description of the comparator enable and flag bits. note: interrupt flag bits get set when an interrupt condition occurs regardless of the state of its corresponding enable bit or the global enable bit, gie (intcon<7>). register 4-3: intcon register (address 0bh or 8bh) r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-x gie peie t0ie inte rbie t0if intf rbif r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por reset -x = unknown at por reset bit7 bit0 bit 7: gie: global interrupt enable bit 1 = enables all un-masked interrupts 0 = disables all interrupts bit 6: peie : peripheral interrupt enable bit 1 = enables all un-masked peripheral interrupts 0 = disables all peripheral interrupts bit 5: t0ie : tmr0 overflow interrupt enable bit 1 = enables the tmr0 interrupt 0 = disables the tmr0 interrupt bit 4: inte : rb0/int external interrupt enable bit 1 = enables the rb0/int external interrupt 0 = disables the rb0/int external interrupt bit 3: rbie : rb port change interrupt enable bit 1 = enables the rb port change interrupt 0 = disables the rb port change interrupt bit 2: t0if : tmr0 overflow interrupt flag bit 1 = tmr0 register has overflowed (must be cleared in software) 0 = tmr0 register did not overflow bit 1: intf : rb0/int external interrupt flag bit 1 = the rb0/int external interrupt occurred (must be cleared in software) 0 = the rb0/int external interrupt did not occur bit 0: rbif : rb port change interrupt flag bit 1 = when at least one of the rb7:rb4 pins changed state (must be cleared in software) 0 = none of the rb7:rb4 pins have changed state
pic16f62x ds40300b-page 22 preliminary 1999 microchip technology inc. 4.2.2.4 pie1 register this register contains interrupt enable bits. register 4-4: pie1 register (address 8ch) r/w-0 r/w-0 r/w-0 r/w-0 u r/w-0 r/w-0 r/w-0 eeie cmie rcie txie - ccp1ie tmr2ie tmr1ie r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por reset bit7 bit0 bit 7: eeie: ee write complete interrupt enable bit 1 = enables the ee write complete interrupt 0 = disables the ee write complete interrupt bit 6: cmie : comparator interrupt enable bit 1 = enables the comparator interrupt 0 = disables the comparator interrupt bit 5: rcie : usart receive interrupt enable bit 1 = enables the usart receive interrupt 0 = disables the usart receive interrupt bit 4: txie : usart transmit interrupt enable bit 1 = enables the usart transmit interrupt 0 = disables the usart transmit interrupt bit 3: unimplemented : read as 0 bit 2: ccp1ie : ccp1 interrupt enable bit 1 = enables the ccp1 interrupt 0 = disables the ccp1 interrupt bit 1: tmr2ie : tmr2 to pr2 match interrupt enable bit 1 = enables the tmr2 to pr2 match interrupt 0 = disables the tmr2 to pr2 match interrupt bit 0: tmr1ie : tmr1 overflow interrupt enable bit 1 = enables the tmr1 overflow interrupt 0 = disables the tmr1 overflow interrupt
1999 microchip technology inc. preliminary ds40300b-page 23 pic16f62x 4.2.2.5 pir1 register this register contains interrupt flag bits. note: interrupt flag bits get set when an interrupt condition occurs regardless of the state of its corresponding enable bit or the global enable bit, gie (intcon<7>). user software should ensure the appropriate interrupt flag bits are clear prior to enabling an interrupt. register 4-5: pir1 register (address 0ch) r/w-0 r/w-0 r-0 r-0 u r/w-0 r/w-0 r/w-0 eeif cmif rcif txif - ccp1if tmr2if tmr1if r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por reset bit7 bit0 bit 7: eeif: eeprom write operation interrupt flag bit 1 = the write operation completed (must be cleared in software) 0 = the write operation has not completed or has not been started bit 6: cmif : comparator interrupt flag bit 1 = comparator input has changed 0 = comparator input has not changed bit 5: rcif : usart receive interrupt flag bit 1 = the usart receive buffer is full 0 = the usart receive buffer is empty bit 4: txif : usart transmit interrupt flag bit 1 = the usart transmit buffer is empty 0 = the usart transmit buffer is full bit 3: unimplemented : read as 0 bit 2: ccp1if : ccp1 interrupt flag bit capture mode 1 = a tmr1 register capture occurred (must be cleared in software) 0 = no tmr1 register capture occurred compare mode 1 = a tmr1 register compare match occurred (must be cleared in software) 0 = no tmr1 register compare match occurred pwm mode unused in this mode bit 1: tmr2if : tmr2 to pr2 match interrupt flag bit 1 = tmr2 to pr2 match occurred (must be cleared in software) 0 = no tmr2 to pr2 match occurred bit 0: tmr1if : tmr1 overflow interrupt flag bit 1 = tmr1 register overflowed (must be cleared in software) 0 = tmr1 register did not overflow
pic16f62x ds40300b-page 24 preliminary 1999 microchip technology inc. 4.2.2.6 pcon register the pcon register contains flag bits to differentiate between a power-on reset, an external mclr reset, wdt reset or a brown-out detect. note: bod is unknown on power-on reset. it must then be set by the user and checked on subsequent resets to see if bod is cleared, indicating a brown-out has occurred. the bod status bit is a "don't care" and is not necessarily predictable if the brown-out circuit is disabled (by programming boren bit in the configuration word). register 4-6: pcon register (address 8eh) u-0 u-0 u-0 u-0 r/w-1 u-0 r/w-q r/w-q oscf por bod r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por reset bit7 bit0 bit 7-4,2: unimplemented: read as '0' bit 3: oscf : intrc/er oscillator speed 1 = 4 mhz typical (1) 0 = 37 khz typical bit 1: por : power-on reset status bit 1 = no power-on reset occurred 0 = a power-on reset occurred (must be set in software after a power-on reset occurs) bit 0: bod : brown-out detect status bit 1 = no brown-out reset occurred 0 = a brown-out reset occurred (must be set in software after a brown-out reset occurs) note 1: when in er oscillator mode, setting oscf = 1 will cause the oscillator speed to change to the speed specified by the external resistor.
1999 microchip technology inc. preliminary ds40300b-page 25 pic16f62x 4.3 pcl and pclath the program counter (pc) is 13-bits wide. the low byte comes from the pcl register, which is a readable and writable register. the high byte (pc<12:8>) is not directly readable or writable and comes from pclath. on any reset, the pc is cleared. figure 4-7 shows the two situations for the loading of the pc. the upper example in the figure shows how the pc is loaded on a write to pcl (pclath<4:0> ? pch). the lower example in the figure shows how the pc is loaded during a call or goto instruction (pclath<4:3> ? pch). figure 4-7: loading of pc in different situations 4.3.1 computed goto a computed goto is accomplished by adding an offset to the program counter ( addwf pcl ). when doing a table read using a computed goto method, care should be exercised if the table location crosses a pcl memory boundary (each 256 byte block). refer to the application note implementing a table read" (an556). pc 12 8 7 0 5 pclath<4:0> pclath instruction with alu result goto, call opcode <10:0> 8 pc 12 11 10 0 11 pclath<4:3> pch pcl 87 2 pclath pch pcl pcl as destination 4.3.2 stack the pic16f62x family has an 8 level deep x 13-bit wide hardware stack (figure 4-1 and figure 4-2). the stack space is not part of either program or data space and the stack pointer is not readable or writable. the pc is pushed onto the stack when a call instruction is executed or an interrupt causes a branch. the stack is poped in the event of a return, retlw or a ret- fie instruction execution. pclath is not affected by a push or pop operation. the stack operates as a circular buffer. this means that after the stack has been pushed eight times, the ninth push overwrites the value that was stored from the first push. the tenth push overwrites the second push (and so on). note 1: there are no status bits to indicate stack overflow or stack underflow conditions. note 2: there are no instructions/mnemonics called push or pop. these are actions that occur from the execution of the call, return, retlw and retfie instructions, or the vectoring to an interrupt address.
pic16f62x ds40300b-page 26 preliminary 1999 microchip technology inc. 4.4 indirect addressing, indf and fsr registers the indf register is not a physical register. addressing the indf register will cause indirect addressing. indirect addressing is possible by using the indf register. any instruction using the indf register actually accesses data pointed to by the file select register (fsr). reading indf itself indirectly will produce 00h. writing to the indf register indirectly results in a no-operation (although sta- tus bits may be affected). an effective 9-bit address is obtained by concatenating the 8-bit fsr register and the irp bit (status<7>), as shown in figure 4-8. a simple program to clear ram location 20h-2fh using indirect addressing is shown in example 4-1. example 4-1: indirect addressing movlw 0x20 ;initialize pointer movwf fsr ;to ram next clrf indf ;clear indf register incf fsr ;inc pointer btfss fsr,4 ;all done? goto next ;no clear next ;yes continue continue: figure 4-8: direct/indirect addressing pic16f62x for memory map detail see figure 4-3. data memory indirect addressing direct addressing bank select location select rp1 rp0 6 0 from opcode irp fsr register 7 0 bank select location select 00 01 10 11 180h 1ffh 00h 7fh bank 0 bank 1 bank 2 bank 3
1999 microchip technology inc. preliminary ds40300b-page 27 pic16f62x 5.0 i/o ports the pic16f62x have two ports, porta and portb. some pins for these i/o ports are multiplexed with an alternate function for the peripheral features on the device. in general, when a peripheral is enabled, that pin may not be used as a general purpose i/o pin. 5.1 porta and trisa registers porta is an 8-bit wide latch. ra4 is a schmitt trigger input and an open drain output. port ra4 is multiplexed with the t0cki clock input. ra5 is a schmitt trigger input only and has no output drivers. all other ra port pins have schmitt trigger input levels and full cmos output drivers. all pins have data direction bits (tris registers) which can configure these pins as input or output. a '1' in the trisa register puts the corresponding output driver in a hi- impedance mode. a '0' in the trisa register puts the contents of the output latch on the selected pin(s). reading the porta register reads the status of the pins whereas writing to it will write to the port latch. all write operations are read-modify-write operations. so a write to a port implies that the port pins are first read, then this value is modified and written to the port data latch. the porta pins are multiplexed with comparator and voltage reference functions. the operation of these pins are selected by control bits in the cmcon (comparator control register) register and the vrcon (voltage reference control register) register. when selected as a comparator input, these pins will read as '0's. trisa controls the direction of the ra pins, even when they are being used as comparator inputs. the user must make sure to keep the pins configured as inputs when using them as comparator inputs. the ra2 pin will also function as the output for the voltage reference. when in this mode, the v ref pin is a very high impedance output. the user must configure trisa<2> bit as an input and use high impedance loads. in one of the comparator modes defined by the cmcon register, pins ra3 and ra4 become outputs of the comparators. the trisa<4:3> bits must be cleared to enable outputs to use this function. example 5-1: initializing porta note 1: on reset, the trisa register is set to all inputs. the digital inputs are disabled and the comparator inputs are forced to ground to reduce excess current con- sumption. note 2: when ra6/osc2/clkout is configured as clkout, the corresponding tris bit is overridden and the pin is configured as an output. the porta data bit reads 0, and the porta tris bit reads 0. clrf porta ;initia lize porta by setting ;output data latches movlw 0x07 ;turn comparators off and movwf cmcon ;enable pins for i/o ;functions bcf status, rp1 bsf status, rp0 ;select bank1 movlw 0x1f ;value used to initialize ;data direction movwf trisa ;set ra<4:0> as inputs ;trisa<7:5> are always ;read as '0'.
pic16f62x ds40300b-page 28 preliminary 1999 microchip technology inc. figure 5-1: block diagram of ra0/an0:ra1/an1 pins data bus q d q ck p n wr porta wr trisa data latch tris latch rd trisa rd porta analog v ss v dd i/o pin q d q ck input mode d q en to comparator schmitt trigger input buffer v dd v ss figure 5-2: block diagram of ra2/v ref pin data bus q d q ck p n wr porta wr trisa data latch tris latch rd trisa rd porta analog v ss v dd ra2 pin q d q ck input mode d q en to comparator schmitt trigger input buffer v roe v ref v dd v ss
1999 microchip technology inc. preliminary ds40300b-page 29 pic16f62x figure 5-3: block diagram of the ra3/an3 pin figure 5-4: block diagram of ra4/t0cki pin data bus q d q ck p n wr porta wr trisa data latch tris latch rd trisa rd porta analog v ss v dd ra3 pin q d q ck d q en to comparator schmitt trigger input buffer input mode comparator output comparator mode = 110 1 0 v dd v ss data bus q d q ck n wr porta wr trisa data latch tris latch rd trisa rd porta v ss ra4 pin q d q ck d q en tmr0 clock input schmitt trigger input buffer comparator output comparator mode = 110 1 0 v ss
pic16f62x ds40300b-page 30 preliminary 1999 microchip technology inc. figure 5-5: block diagram of the ra5/mclr /thv pin d q en hv detect mclr filter(1) ra5/mclr /thv rd port mclr circuit program mode mclre data bus q d q ck p n wr port wr tris data latch tris latch rd tris v ss v dd q d q ck v dd v ss
1999 microchip technology inc. preliminary ds40300b-page 31 pic16f62x figure 5-6: block diagram of ra6/osc2/clkout pin data bus q d q ck p n wr porta wr trisa data latch tris latch rd trisa rd porta v ss v dd ra6/osc2/clkout pin q d q ck d q en schmitt trigger input buffer oscillator circuit from osc1 (fosc=100, 101, 110, 111) (fosc=110, 100) 1 0 clkout (fosc/4) (fosc=101,111) clkout is 1/4 of the fosc frequency. v dd v ss
pic16f62x ds40300b-page 32 preliminary 1999 microchip technology inc. figure 5-7: block diagram of ra7/osc1/clkin pin data bus q d q ck p n wr porta wr trisa data latch tris latch rd trisa rd porta v ss v dd ra7/osc1/clkin pin q d q ck d q en schmitt trigger input buffer oscillator circuit to osc2 (fosc=101, 100) (fosc=101, 100) schmitt trigger clkin to core v dd v ss
1999 microchip technology inc. preliminary ds40300b-page 33 pic16f62x table 5-1: porta functions table 5-2: summary of registers associated with porta name bit # buffer type function ra0/an0 bit0 st bi-directional i/o port/comparator input ra1/an1 bit1 st bi-directional i/o port/comparator input ra2/an2/v ref bit2 st bi-directional i/o port/analog/comparator input or v ref output ra3/an3 bit3 st bi-directional i/o port/analog/comparator input/comparator output ra4/t0cki bit4 st bi-directional i/o port/external clock input for tmr0 or comparator output. output is open drain type. ra5/mclr /thv bit5 st input port/master clear (reset input/programming voltage input. when configured as mclr , this pin is an active low reset to the device. voltage on mclr /thv must not exceed v dd during normal device operation. ra6/osc2/clk- out bit6 st bi-directional i/o port/oscillator crystal output. connects to crystal or res- onator in crystal oscillator mode. in er mode, osc2 pin outputs clkout which has 1/4 the frequency of osc1, and denotes the instruction cycle rate. ra7/osc1/clkin bit7 st bi-directional i/o port/oscillator crystal input/external clock source input. legend: st = schmitt trigger input address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por value on all other resets 05h porta ra7 ra6 ra5 ra4 ra3 ra2 ra1 ra0 xxxx 0000 xxxu 0000 85h trisa trisa7 trisa6 trisa4 trisa3 trisa2 trisa1 trisa0 11-1 1111 11-1 1111 1fh cmcon c2out c1out c2inv c1inv cis cm2 cm1 cm0 0000 0000 0000 0000 9fh vrcon vren vroe vrr vr3 vr2 vr1 vr0 000- 0000 000- 0000 legend: = unimplemented locations, read as 0, u = unchanged, x = unknown note: shaded bits are not used by porta.
pic16f62x ds40300b-page 34 preliminary 1999 microchip technology inc. 5.2 portb and trisb registers portb is an 8-bit wide bi-directional port. the corresponding data direction register is trisb. a '1' in the trisb register puts the corresponding output driver in a high impedance mode. a '0' in the trisb register puts the contents of the output latch on the selected pin(s). portb is multiplexed with the interrupt, usart, ccp module and the tmr1 clock input/output. the standard port functions and the alternate port functions are shown in table 5-3. reading portb register reads the status of the pins, whereas writing to it will write to the port latch. all write operations are read-modify-write operations. so a write to a port implies that the port pins are first read, then this value is modified and written to the port data latch. each of the portb pins has a weak internal pull-up ( ? 200 m a typical). a single control bit can turn on all the pull-ups. this is done by clearing the rbpu (option<7>) bit. the weak pull-up is automatically turned off when the port pin is configured as an output. the pull-ups are disabled on power-on reset. four of portbs pins, rb7:rb4, have an interrupt on change feature. only pins configured as inputs can cause this interrupt to occur (i.e., any rb7:rb4 pin configured as an output is excluded from the interrupt on change comparison). the input pins (of rb7:rb4) are compared with the old value latched on the last read of portb. the mismatch outputs of rb7:rb4 are ored together to generate the rbif interrupt (flag latched in intcon<0>). this interrupt can wake the device from sleep. the user, in the interrupt service routine, can clear the interrupt in the following manner: a) any read or write of portb. this will end the mismatch condition. b) clear flag bit rbif. a mismatch condition will continue to set flag bit rbif. reading portb will end the mismatch condition, and allow flag bit rbif to be cleared. this interrupt on mismatch feature, together with software configurable pull-ups on these four pins allow easy interface to a key pad and make it possible for wake-up on key-depression. (see an552 in the microchip embedded control handbook .) the interrupt on change feature is recommended for wake-up on key depression operation and operations where portb is only used for the interrupt on change feature. polling of portb is not recommended while using the interrupt on change feature. note: if a change on the i/o pin should occur when the read operation is being executed (start of the q2 cycle), then the rbif inter- rupt flag may not get set.
1999 microchip technology inc. preliminary ds40300b-page 35 pic16f62x figure 5-8: block diagram of rb0/int pin data bus wr portb wr trisb rd portb data latch tris latch rb0/int pin int input q d ck q d ck en qd en rd trisb rbpu p v dd weak pull-up schmitt trigger buffer ttl input buffer v dd v ss
pic16f62x ds40300b-page 36 preliminary 1999 microchip technology inc. figure 5-9: block diagram of rb1/tx/dt pin data latch tris latch rd trisb p v ss q d q ck q d q ck n v dd 0 1 rd portb wr portb wr trisb schmitt trigger peripheral oe (2) data bus port/peripheral select (1) usart data output rd portb rb1/rx/dt usart receive input rbpu v dd weak pull-up ttl input buffer p pin note 1: port/peripheral select signal selects between port data and peripheral output. note 2: peripheral oe( output enable) is only active if peripheral select is active. en qd v dd v ss
1999 microchip technology inc. preliminary ds40300b-page 37 pic16f62x figure 5-10: block diagram of rb2/tx/ck pin data latch tris latch rd trisb p vss q d q ck q d q ck en qd en n v dd 0 1 rd portb wr portb wr trisb schmitt trigger peripheral oe (2) data bus port/peripheral select (1) usart tx/ck output rd portb rb2/tx/ck usart slave clock in rbpu v dd weak pull-up ttl input buffer p note 1: port/peripheral select signal selects between port data and peripheral output. note 2: peripheral oe( output enable) is only active if peripheral select is active. pin v dd v ss
pic16f62x ds40300b-page 38 preliminary 1999 microchip technology inc. figure 5-11: block diagram of the rb3/ccp1 pin data latch tris latch rd trisb p vss q d q ck q d q ck en qd en n v dd 0 1 rd portb wr portb wr trisb schmitt trigger data bus port/peripheral select (1) pwm/compare output rd portb rb3/ccp1 ccp input rbpu v dd weak pull-up p ttl input buffer pin note 1: peripheral select is defined by ccp1m3:ccp1m0. (ccp1con<3:0>) v dd v ss
1999 microchip technology inc. preliminary ds40300b-page 39 pic16f62x figure 5-12: block diagram of rb4/pgm pin data latch tris latch rd trisb p v ss q d q ck q d q ck n v dd rd portb wr portb wr trisb schmitt trigger pgm input lvp data bus rb4/pgm rbpu v dd weak pull-up p from other qd en qd en set rbif rb<7:4> pins rd port q3 q1 ttl input buffer v dd v ss note: the low voltage programming disables the interrupt on change and the weak pullups on rb4.
pic16f62x ds40300b-page 40 preliminary 1999 microchip technology inc. figure 5-13: block diagram of rb5 pin data bus wr portb wr trisb rd portb data latch tris latch rb5 pin q d ck q d ck ttl input buffer rd trisb rbpu p v dd weak pull-up from other qd en qd en set rbif rb<7:4> pins rd port q3 q1 v dd v ss
1999 microchip technology inc. preliminary ds40300b-page 41 pic16f62x figure 5-14: block diagram of rb6/t1oso/t1cki pin data latch tris latch rd trisb p v ss q d q ck q d q ck n v dd rd portb wr portb wr trisb schmitt trigger t1oscen data bus rb6/ tmr1 clock rbpu v dd weak pull-up p from rb7 t1oso/ t1cki pin from other qd en set rbif rb<7:4> pins rd port q3 q1 serial programming clock ttl input buffer tmr1 oscillator qd en v dd v ss
pic16f62x ds40300b-page 42 preliminary 1999 microchip technology inc. figure 5-15: block diagram of the rb7/t1osi pin data latch tris latch rd trisb p vss q d q ck q d q ck n v dd rd portb wr portb wr trisb t10scen data bus rb7/t1osi t1oscen to r b6 rbpu v dd weak pull-up p pin ttl input buffer from other qd en qd en set rbif rb<7:4> pins rd port q3 q1 serial programming input schmitt trigger tmr1 oscillator v dd v ss
1999 microchip technology inc. preliminary ds40300b-page 43 pic16f62x table 5-3: portb functions table 5-4: summary of registers associated with port name bit # buffer type function rb0/int bit0 ttl/st (1) bi-directional i/o port/external interrupt. can be software programmed for internal weak pull-up. rb1/rx/dt bit1 ttl/st (3) bi-directional i/o port/ usart receive pin/synchronous data i/o. can be software programmed for internal weak pull-up. rb2/tx/ck bit2 ttl/st (3) bi-directional i/o port/ usart transmit pin/synchronous clock i/o. can be software programmed for internal weak pull-up. rb3/ccp1 bit3 ttl/st (4) bi-directional i/o port/capture/compare/pwm i/o. can be software pro- grammed for internal weak pull-up. rb4/pgm bit4 ttl/st (5) bi-directional i/o port/low voltage programming input pin. wake-up from sleep on pin change. can be software programmed for internal weak pull-up. when low voltage programming is enabled, the interrupt on pin change and weak pull-up resistor are disabled. rb5 bit5 ttl bi-directional i/o port/wake-up from sleep on pin change. can be soft- ware programmed for internal weak pull-up. rb6/t1oso/t1cki bit6 ttl/st (2) bi-directional i/o port/timer1 oscillator output/timer1 clock input. wake up from sleep on pin change. can be software programmed for internal weak pull-up. rb7/t1osi bit7 ttl/st (2) bi-directional i/o port/timer1 oscillator input. wake up from sleep on pin change. can be software programmed for internal weak pull-up. legend: st = schmitt trigger, ttl = ttl input note 1: this buffer is a schmitt trigger input when configured as the external interrupt. note 2: this buffer is a schmitt trigger input when used in serial programming mode. note 3: this buffer is a schmitt trigger i/o when used in usart/synchronous mode. note 4: this buffer is a schmitt trigger i/o when used in ccp mode. note 5: this buffer is a schmitt trigger input when used in low voltage program mode. address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por value on all other resets 06h portb rb7 rb6 rb5 rb4 rb3 rb2 rb1 rb0 xxxx xxxx uuuu uuuu 86h trisb trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 1111 1111 1111 1111 81h option rbpu intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 1111 1111 legend: u = unchanged, x = unknown note: shaded bits are not used by portb.
pic16f62x ds40300b-page 44 preliminary 1999 microchip technology inc. 5.3 i/o programming considerations 5.3.1 bi-directional i/o ports any instruction which writes, operates internally as a read followed by a write operation. the bcf and bsf instructions, for example, read the register into the cpu, execute the bit operation and write the result back to the register. caution must be used when these instructions are applied to a port with both inputs and outputs defined. for example, a bsf operation on bit5 of portb will cause all eight bits of portb to be read into the cpu. then the bsf operation takes place on bit5 and portb is written to the output latches. if another bit of portb is used as a bidirectional i/o pin (e.g., bit0) and it is defined as an input at this time, the input signal present on the pin itself would be read into the cpu and re-written to the data latch of this particular pin, overwriting the previous content. as long as the pin stays in the input mode, no problem occurs. however, if bit0 is switched into output mode later on, the content of the data latch may now be unknown. reading a port register, reads the values of the port pins. writing to the port register writes the value to the port latch. when using read modify write instructions (ex. bcf, bsf , etc.) on a port, the value of the port pins is read, the desired operation is done to this value, and this value is then written to the port latch. example 5-2 shows the effect of two sequential read-modify-write instructions (ex., bcf, bsf , etc.) on an i/o port. a pin actively outputting a low or high should not be driven from external devices at the same time in order to change the level on this pin (wired-or, wired-and). the resulting high output currents may damage the chip. example 5-2: read-modify-write instructions on an i/o port 5.3.2 successive operations on i/o ports the actual write to an i/o port happens at the end of an instruction cycle, whereas for reading, the data must be valid at the beginning of the instruction cycle (figure 5-16). therefore, care must be exercised if a write followed by a read operation is carried out on the same i/o port. the sequence of instructions should be such to allow the pin voltage to stabilize (load dependent) before the next instruction which causes that file to be read into the cpu is executed. otherwise, the previous state of that pin may be read into the cpu rather than the new state. when in doubt, it is better to separate these instructions with a nop or another instruction not accessing this i/o port. ; ; initial port settings: portb<7:4> inputs ; portb<3:0> outputs ; ; portb<7:6> have external pull-up and are not connected to other circuitry ; ; port latch port pins ; ---------- ---------- bdf status,rpo ; bcf portb, 7 ; 01pp pppp 11pp pppp bcf portb, 6 ; 10pp pppp 11pp pppp bsf status,rp0 ; bcf trisb, 7 ; 10pp pppp 11pp pppp bcf trisb, 6 ; 10pp pppp 10pp pppp ; ; note that the user may have expected the pin ; values to be 00pp pppp. the 2nd bcf caused ; rb7 to be latched as the pin value (high). figure 5-16: successive i/o operation note: this example shows write to portb followed by a read from portb. note that: data setup time = (0.25 t cy - t pd ) where t cy = instruction cycle and tpd = propagation delay of q1 cycle to output valid. therefore, at higher clock frequencies, a write followed by a read may be problematic. q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 rb <7:0> port pin sampled here pc pc + 1 pc + 2 pc + 3 nop nop movf portb, w read portb movwf portb write to portb pc instruction fetched t pd execute movwf portb execute movf portb, w execute nop rb<7:0> pc instruction fetched mowf portb write to portb movf portb, w read to portb nop nop execute movwf portb execute movwf portb execute nop t pd port pin sampled here pc + 1 pc + 2 pc + 3 pc q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4
1999 microchip technology inc. preliminary ds40300b-page 45 pic16f62x 6.0 timer0 module the timer0 module timer/counter has the following features: ? 8-bit timer/counter ? readable and writable ? 8-bit software programmable prescaler ? internal or external clock select ? interrupt on overflow from ffh to 00h ? edge select for external clock figure 6-1 is a simplified block diagram of the timer0 module. timer mode is selected by clearing the t0cs bit (option<5>). in timer mode, the tmr0 will increment every instruction cycle (without prescaler). if timer0 is written, the increment is inhibited for the following two cycles (figure 6-2 and figure 6-3). the user can work around this by writing an adjusted value to tmr0. counter mode is selected by setting the t0cs bit. in this mode timer0 will increment either on every rising or falling edge of pin ra4/t0cki. the incrementing edge is determined by the source edge (t0se) control bit (option<4>). clearing the t0se bit selects the rising edge. restrictions on the external clock input are discussed in detail in section 6.2. the prescaler is shared between the timer0 module and the watchdog timer. the prescaler assignment is controlled in software by the control bit psa (option<3>). clearing the psa bit will assign the prescaler to timer0. the prescaler is not readable or writable. when the prescaler is assigned to the timer0 module, prescale value of 1:2, 1:4, ..., 1:256 are selectable. section 6.3 details the operation of the prescaler. 6.1 timer0 interrupt timer0 interrupt is generated when the tmr0 register timer/counter overflows from ffh to 00h. this overflow sets the t0if bit. the interrupt can be masked by clearing the t0ie bit (intcon<5>). the t0if bit (intcon<2>) must be cleared in software by the timer0 module interrupt service routine before re-enabling this interrupt. the timer0 interrupt cannot wake the processor from sleep since the timer is shut off during sleep. see figure 6-4 for timer0 interrupt timing. figure 6-1: timer0 block diagram figure 6-2: timer0 (tmr0) timing: internal clock/no prescaler note 1: bits t0se, t0cs, ps2, ps1, ps0 and psa are located in the option register. 2: the prescaler is shared with watchdog timer (figure 6-6) ra4/t0cki t0se 0 1 1 0 pin t0cs f osc /4 programmable prescaler sync with internal clocks tmr0 psout (2 t cy delay) psout data bus 8 set flag bit t0if on overflow psa ps2:ps0 pc-1 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 pc (program counter) instruction fetch tmr0 pc pc+1 pc+2 pc+3 pc+4 pc+5 pc+6 t0 t0+1 t0+2 nt0 nt0+1 nt0+2 t0 movwf tmr0 movf tmr0,w movf tmr0,w movf tmr0,w movf tmr0,w movf tmr0,w write tmr0 executed read tmr0 reads nt0 read tmr0 reads nt0 read tmr0 reads nt0 read tmr0 reads nt0 + 1 read tmr0 reads nt0 + 2 instruction executed
pic16f62x ds40300b-page 46 preliminary 1999 microchip technology inc. figure 6-3: timer0 timing: internal clock/prescale 1:2 figure 6-4: timer0 interrupt timing pc-1 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 pc (program counter) instruction fetch tmr0 pc pc+1 pc+2 pc+3 pc+4 pc+5 pc+6 t0 nt0+1 movwf tmr0 movf tmr0,w movf tmr0,w movf tmr0,w movf tmr0,w movf tmr0,w write tmr0 executed read tmr0 reads nt0 read tmr0 reads nt0 read tmr0 reads nt0 read tmr0 reads nt0 read tmr0 reads nt0 + 1 t0+1 nt0 instruction execute q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 1 1 osc1 clkout(3) tmr0 timer t0if bit (intcon<2>) feh gie bit (intcon<7>) instruction flow pc instruction fetched pc pc +1 pc +1 0004h 0005h instruction executed inst (pc) inst (pc-1) inst (pc+1) inst (pc) inst (0004h) inst (0005h) inst (0004h) dummy cycle dummy cycle ffh 00h 01h 02h note 1: t0if interrupt flag is sampled here (every q1). 2: interrupt latency = 3t cy , where t cy = instruction cycle time. 3: clkout is available only in er and intrc (with clockout) oscillator modes. interrupt latency time
1999 microchip technology inc. preliminary ds40300b-page 47 pic16f62x 6.2 using timer0 with external clock when an external clock input is used for timer0, it must meet certain requirements. the external clock requirement is due to internal phase clock (t osc ) synchronization. also, there is a delay in the actual incrementing of timer0 after synchronization. 6.2.1 external clock synchronization when no prescaler is used, the external clock input is the same as the prescaler output. the synchronization of t0cki with the internal phase clocks is accomplished by sampling the prescaler output on the q2 and q4 cycles of the internal phase clocks (figure 6-5). therefore, it is necessary for t0cki to be high for at least 2t osc (and a small rc delay of 20 ns) and low for at least 2t osc (and a small rc delay of 20 ns). refer to the electrical specification of the desired device. when a prescaler is used, the external clock input is divided by the asynchronous ripple-counter type prescaler so that the prescaler output is symmetrical. for the external clock to meet the sampling requirement, the ripple-counter must be taken into account. therefore, it is necessary for t0cki to have a period of at least 4t osc (and a small rc delay of 40 ns) divided by the prescaler value. the only requirement on t0cki high and low time is that they do not violate the minimum pulse width requirement of 10 ns. refer to parameters 40, 41 and 42 in the electrical specification of the desired device. 6.2.2 timer0 increment delay since the prescaler output is synchronized with the internal clocks, there is a small delay from the time the external clock edge occurs to the time the tmr0 is actually incremented. figure 6-5 shows the delay from the external clock edge to the timer incrementing. figure 6-5: timer0 timing with external clock q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 external clock input or prescaler output (2) external clock/prescaler output after sampling increment timer0 (q4) timer0 t0 t0 + 1 t0 + 2 small pulse misses sampling (3) (1) note 1: delay from clock input change to timer0 increment is 3tosc to 7tosc. (duration of q = tosc). therefore, the error in measuring the interval between two edges on timer0 input = 4tosc max. 2: external clock if no prescaler selected, prescaler output otherwise. 3: the arrows indicate the points in time where sampling occurs.
pic16f62x ds40300b-page 48 preliminary 1999 microchip technology inc. 6.3 prescaler an 8-bit counter is available as a prescaler for the timer0 module, or as a postscaler for the watchdog timer, respectively (figure 6-6). for simplicity, this counter is being referred to as prescaler throughout this data sheet. note that there is only one prescaler available which is mutually exclusive between the timer0 module and the watchdog timer. thus, a prescaler assignment for the timer0 module means that there is no prescaler for the watchdog timer, and vice-versa. the psa and ps2:ps0 bits (option<3:0>) determine the prescaler assignment and prescale ratio. when assigned to the timer0 module, all instructions writing to the tmr0 register (e.g., clrf 1, movwf 1, bsf 1, x....etc. ) will clear the pres- caler. when assigned to wdt, a clrwdt instruction will clear the prescaler along with the watchdog timer. the prescaler is not readable or writable. figure 6-6: block diagram of the timer0/wdt prescaler t0cki t0se pin m u x clkout (=fosc/4) sync 2 cycles tmr0 reg 8-bit prescaler 8-to-1mux m u x m u x watchdog timer psa 0 1 0 1 wdt time-out ps0 - ps2 8 note: t0se, t0cs, psa, ps0-ps2 are bits in the option register. psa wdt enable bit m u x 0 1 0 1 data bus set flag bit t0if on overflow 8 psa t0cs
1999 microchip technology inc. preliminary ds40300b-page 49 pic16f62x 6.3.1 switching prescaler assignment the prescaler assignment is fully under software control ( i.e., it can be changed on the fly during program execution). to avoid an unintended device reset, the following instruction sequence (example 6-1) must be executed when changing the prescaler assignment from timer0 to wdt. example 6-1: changing prescaler (timer0 ? wdt) 1.bcf status, rp0 ;skip if already in ; bank 0 2.clrwdt ;clear wdt 3.clrf tmr0 ;clear tmr0 & prescaler 4.bsf status, rp0 ;bank 1 5.movlw '00101111b ;these 3 lines (5, 6, 7) 6.movwf option ; are required only if ; desired ps<2:0> are 7.clrwdt ; 000 or 001 8.movlw '00101xxxb ;set postscaler to 9.movwf option ; desired wdt rate 10.bcf status, rp0 ;return to bank 0 to change prescaler from the wdt to the tmr0 module use the sequence shown in example 6-2. this precaution must be taken even if the wdt is disabled. example 6-2: changing prescaler (wdt ? timer0) clrwdt ;clear wdt and ;prescaler bsf status, rp0 movlw b'xxxx0xxx' ;select tmr0, new ;prescale value and ;clock source movwf option_reg bcf status, rp0 table 6-1: registers associated with timer0 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por value on all other resets 01h tmr0 timer0 module register xxxx xxxx uuuu uuuu 0bh/8bh/ 10bh/18bh intcon gie t0ie inte rbie t0if intf rbif 0000 000x 0000 000u 81h option rbpu intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 1111 1111 85h trisa trisa7 trisa6 trisa4 trisa3 trisa2 trisa1 trisa0 11-1 1111 11-1 1111 legend: = unimplemented locations, read as 0, u = unchanged, x = unknown note: shaded bits are not used by tmr0 module.
pic16f62x ds40300b-page 50 preliminary 1999 microchip technology inc. 7.0 timer1 module the timer1 module is a 16-bit timer/counter consisting of two 8-bit registers (tmr1h and tmr1l) which are readable and writable. the tmr1 register pair (tmr1h:tmr1l) increments from 0000h to ffffh and rolls over to 0000h. the tmr1 interrupt, if enabled, is generated on overflow which is latched in interrupt flag bit tmr1if (pir1<0>). this interrupt can be enabled/disabled by setting/clearing tmr1 interrupt enable bit tmr1ie (pie1<0>). timer1 can operate in one of two modes: ?as a timer ?as a counter the operating mode is determined by the clock select bit, tmr1cs (t1con<1>). in timer mode, timer1 increments every instruction cycle. in counter mode, it increments on every rising edge of the external clock input. timer1 can be enabled/disabled by setting/clearing control bit tmr1on (t1con<0>). timer1 also has an internal reset input. this reset can be generated by the ccp module (section 10.0). register 7-1 shows the timer1 control register. for the pic16f627 and pic16f628, when the timer1 oscillator is enabled (t1oscen is set), the rb7/t1osi and rb6/t1oso/t1cki pins become inputs. that is, the trisb<7:6> value is ignored. register 7-1: t1con: timer1 control register (address 10h) u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 t1ckps1 t1ckps0 t1oscen t1sync tmr1cs tmr1on r = readable bit w = writable bit u = unimplemented bit, read as 0 - n = value at por reset bit7 bit0 bit 7-6: unimplemented: read as '0' bit 5-4: t1ckps1:t1ckps0 : timer1 input clock prescale select bits 11 = 1:8 prescale value 10 = 1:4 prescale value 01 = 1:2 prescale value 00 = 1:1 prescale value bit 3: t1oscen : timer1 oscillator enable control bit 1 = oscillator is enabled 0 = oscillator is shut off note: the oscillator inverter and feedback resistor are turned off to eliminate power drain bit 2: t1sync : timer1 external clock input synchronization control bit tmr1cs = 1 1 = do not synchronize external clock input 0 = synchronize external clock input tmr1cs = 0 this bit is ignored. timer1 uses the internal clock when tmr1cs = 0. bit 1: tmr1cs : timer1 clock source select bit 1 = external clock from pin rb6/t1oso/t1cki (on the rising edge) 0 = internal clock (f osc /4) bit 0: tmr1on : timer1 on bit 1 = enables timer1 0 = stops timer1
1999 microchip technology inc. preliminary ds40300b-page 51 pic16f62x 7.1 timer1 operation in timer mode timer mode is selected by clearing the tmr1cs (t1con<1>) bit. in this mode, the input clock to the timer is f osc /4. the synchronize control bit t1sync (t1con<2>) has no effect since the internal clock is always in sync. 7.2 timer1 operation in synchronized counter mode counter mode is selected by setting bit tmr1cs. in this mode the timer increments on every rising edge of clock input on pin rb7/t1osi when bit t1oscen is set or pin rb6/t1oso/t1cki when bit t1oscen is cleared. if t1sync is cleared, then the external clock input is synchronized with internal phase clocks. the synchro- nization is done after the prescaler stage. the pres- caler stage is an asynchronous ripple-counter. in this configuration, during sleep mode, timer1 will not increment even if the external clock is present, since the synchronization circuit is shut off. the pres- caler however will continue to increment. 7.2.1 external clock input timing for synchronized counter mode when an external clock input is used for timer1 in syn- chronized counter mode, it must meet certain require- ments. the external clock requirement is due to internal phase clock (tosc) synchronization. also, there is a delay in the actual incrementing of tmr1 after syn- chronization. when the prescaler is 1:1, the external clock input is the same as the prescaler output. the synchronization of t1cki with the internal phase clocks is accom- plished by sampling the prescaler output on the q2 and q4 cycles of the internal phase clocks. therefore, it is necessary for t1cki to be high for at least 2tosc (and a small rc delay of 20 ns) and low for at least 2tosc (and a small rc delay of 20 ns). refer to the appropri- ate electrical specifications, parameters 45, 46, and 47. when a prescaler other than 1:1 is used, the external clock input is divided by the asynchronous rip- ple-counter type prescaler so that the prescaler output is symmetrical. in order for the external clock to meet the sampling requirement, the ripple-counter must be taken into account. therefore, it is necessary for t1cki to have a period of at least 4tosc (and a small rc delay of 40 ns) divided by the prescaler value. the only requirement on t1cki high and low time is that they do not violate the minimum pulse width requirements of 10 ns). refer to the appropriate electrical specifica- tions, parameters 40, 42, 45, 46, and 47. figure 7-1: timer1 block diagram tmr1h tmr1l t1osc t1sync tmr1cs t1ckps1:t1ckps0 sleep input t1oscen enable oscillator (1) f osc /4 internal clock tmr1on on/off prescaler 1, 2, 4, 8 synchronize det 1 0 0 1 synchronized clock input 2 rb6/t1oso/t1cki rb7/t1osi note 1: when the t1oscen bit is cleared, the inverter and feedback resistor are turned off. this eliminates power drain. set flag bit tmr1if on overflow tmr1
pic16f62x ds40300b-page 52 preliminary 1999 microchip technology inc. figure 7-2: timer1 incrementing edge t1cki (default high) t1cki (default low) note: arrows indicate counter increments. 7.3 timer1 operation in asynchronous counter mode if control bit t1sync (t1con<2>) is set, the external clock input is not synchronized. the timer continues to increment asynchronous to the internal phase clocks. the timer will continue to run during sleep and can generate an interrupt on overflow which will wake-up the processor. however, special precautions in soft- ware are needed to read/write the timer (section 7.3.2). in asynchronous counter mode, timer1 can not be used as a time-base for capture or compare operations. 7.3.1 external clock input timing with unsynchronized clock if control bit t1sync is set, the timer will increment completely asynchronously. the input clock must meet certain minimum high time and low time requirements. refer to the appropriate electrical specifications sec- tion, timing parameters 45, 46, and 47. 7.3.2 reading and writing timer1 in asynchronous counter mode reading tmr1h or tmr1l while the timer is running, from an external asynchronous clock, will guarantee a valid read (taken care of in hardware). however, the user should keep in mind that reading the 16-bit timer in two 8-bit values itself poses certain problems since the timer may overflow between the reads. for writes, it is recommended that the user simply stop the timer and write the desired values. a write conten- tion may occur by writing to the timer registers while the register is incrementing. this may produce an unpre- dictable value in the timer register. reading the 16-bit value requires some care. example 7-1 is an example routine to read the 16-bit timer value. this is useful if the timer cannot be stopped. example 7-1: reading a 16-bit free-running timer ; all interrupts are disabled movf tmr1h, w ;read high byte movwf tmph ; movf tmr1l, w ;read low byte movwf tmpl ; movf tmr1h, w ;read high byte subwf tmph, w ;sub 1st read ; with 2nd read btfsc status,z ;is result = 0 goto continue ;good 16-bit read ; ; tmr1l may have rolled over between the read ; of the high and low bytes. reading the high ; and low bytes now will read a good value. ; movf tmr1h, w ;read high byte movwf tmph ; movf tmr1l, w ;read low byte movwf tmpl ; ; re-enable the interrupt (if required) continue ;continue with your code 7.4 timer1 oscillator a crystal oscillator circuit is built in between pins t1osi (input) and t1oso (amplifier output). it is enabled by setting control bit t1oscen (t1con<3>). the oscilla- tor is a low power oscillator rated up to 200 khz. it will continue to run during sleep. it is primarily intended for a 32 khz crystal. table 7-1 shows the capacitor selection for the timer1 oscillator. the timer1 oscillator is identical to the lp oscillator. the user must provide a software time delay to ensure proper oscillator start-up. table 7-1: capacitor selection for the timer1 oscillator osc type freq c1 c2 lp 32 khz 33 pf 33 pf 100 khz 15 pf 15 pf 200 khz 15 pf 15 pf these values are for design guidance only.
1999 microchip technology inc. preliminary ds40300b-page 53 pic16f62x 7.5 resetting timer1 using a ccp trigger output if the ccp1 module is configured in compare mode to generate a special event trigger" (ccp1m3:ccp1m0 = 1011 ), this signal will reset timer1. timer1 must be configured for either timer or synchro- nized counter mode to take advantage of this feature. if timer1 is running in asynchronous counter mode, this reset operation may not work. in the event that a write to timer1 coincides with a spe- cial event trigger from ccp1, the write will take prece- dence. in this mode of operation, the ccprxh:ccprxl regis- ters pair effectively becomes the period register for timer1. note: the special event triggers from the ccp1 module will not set interrupt flag bit tmr1if (pir1<0>). 7.6 resetting of timer1 register pair (tmr1h, tmr1l) tmr1h and tmr1l registers are not reset to 00h on a por or any other reset except by the ccp1 special event triggers. t1con register is reset to 00h on a power-on reset or a brown-out reset, which shuts off the timer and leaves a 1:1 prescale. in all other resets, the register is unaffected. 7.7 timer1 prescaler the prescaler counter is cleared on writes to the tmr1h or tmr1l registers. table 7-2: registers associated with timer1 as a timer/counter address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por value on all other resets 0bh/8bh/ 10bh/18bh intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000u 0ch pir1 eeif cmif rcif txif ccp1if tmr2if tmr1if 0000 -000 0000 -000 8ch pie1 eeie cmie rcie txie ccp1ie tmr2ie tmr1ie 0000 -000 0000 -000 0eh tmr1l holding register for the least significant byte of the 16-bit tmr1 register xxxx xxxx uuuu uuuu 0fh tmr1h holding register for the most significant byte of the 16-bit tmr1 register xxxx xxxx uuuu uuuu 10h t1con t1ckps1 t1ckps0 t1oscen t1sync tmr1cs tmr1on --00 0000 --uu uuuu legend: x = unknown, u = unchanged, - = unimplemented read as '0'. shaded cells are not used by the timer1 module.
pic16f62x ds40300b-page 54 preliminary 1999 microchip technology inc. 8.0 timer2 module timer2 is an 8-bit timer with a prescaler and a postscaler. it can be used as the pwm time-base for pwm mode of the ccp module. the tmr2 register is readable and writable, and is cleared on any device reset. the input clock (f osc /4) has a prescale option of 1:1, 1:4 or 1:16, selected by control bits t2ckps1:t2ckps0 (t2con<1:0>). the timer2 module has an 8-bit period register pr2. timer2 increments from 00h until it matches pr2 and then resets to 00h on the next increment cycle. pr2 is a readable and writable register. the pr2 register is ini- tialized to ffh upon reset. the match output of tmr2 goes through a 4-bit postscaler (which gives a 1:1 to 1:16 scaling inclusive) to generate a tmr2 interrupt (latched in flag bit tmr2if, (pir1<1>)). timer2 can be shut off by clearing control bit tmr2on (t2con<2>) to minimize power consumption. register 8-1 shows the timer2 control register. 8.1 timer2 prescaler and postscaler the prescaler and postscaler counters are cleared when any of the following occurs: ? a write to the tmr2 register ? a write to the t2con register ? any device reset (power-on reset, mclr reset, watchdog timer reset, or brown-out reset) tmr2 is not cleared when t2con is written. 8.2 output of tmr2 the output of tmr2 (before the postscaler) is fed to the synchronous serial port module which optionally uses it to generate shift clock. figure 8-1: timer2 block diagram comparator tmr2 sets flag tmr2 reg output (1) reset postscaler prescaler pr2 reg 2 f osc /4 1:1 1:16 1:1, 1:4, 1:16 eq 4 bit tmr2if note 1: tmr2 register output can be software selected by the ssp module as a baud clock. to
1999 microchip technology inc. preliminary ds40300b-page 55 pic16f62x register 8-1: t2con: timer2 control register (address 12h) table 8-1: registers associated with timer2 as a timer/counter u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 toutps3 toutps2 toutps1 toutps0 tmr2on t2ckps1 t2ckps0 r = readable bit w = writable bit u = unimplemented bit, read as 0 - n = value at por reset bit7 bit0 bit 7: unimplemented: read as '0' bit 6-3: toutps3:toutps0 : timer2 output postscale select bits 0000 = 1:1 postscale 0001 = 1:2 postscale ? ? ? 1111 = 1:16 postscale bit 2: tmr2on : timer2 on bit 1 = timer2 is on 0 = timer2 is off bit 1-0: t2ckps1:t2ckps0 : timer2 clock prescale select bits 00 = prescaler is 1 01 = prescaler is 4 1x = prescaler is 16 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por value on all other resets 0bh/8bh/ 10bh/18bh intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000u 0ch pir1 eeif cmif rcif txif ccp1if tmr2if tmr1if 0000 -000 0000 -000 8ch pie1 eeie cmie rcie txie ccp1ie tmr2ie tmr1ie 0000 -000 0000 -000 11h tmr2 timer2 modules register 0000 0000 0000 0000 12h t2con toutps3 toutps2 toutps1 toutps0 tmr2on t2ckps1 t2ckps0 -000 0000 -000 0000 92h pr2 timer2 period register 1111 1111 1111 1111 legend: x = unknown, u = unchanged, - = unimplemented read as '0'. shaded cells are not used by the timer2 module.
pic16f62x ds40300b-page 56 preliminary 1999 microchip technology inc. notes:
1999 microchip technology inc. preliminary ds40300b-page 57 pic16f62x 9.0 comparator module the comparator module contains two analog comparators. the inputs to the comparators are multiplexed with the ra0 through ra3 pins. the on-chip voltage reference (section 11.0) can also be an input to the comparators. the cmcon register, shown in register 9-1, controls the comparator input and output multiplexers. a block diagram of the comparator is shown in figure 9-1. register 9-1: cmcon register (address 01fh) r-0 r-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 c2out c1out c2inv c1inv cis cm2 cm1 cm0 r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por reset bit7 bit0 bit 7: c2out : comparator 2 output when c2inv=0; 1 = c2 v in + > c2 v in C 0 = c2 v in + < c2 v in C when c2inv=1; 0 = c2 v in + > c2 v in C 1 = c2 v in + < c2 v in C bit 6: c1out : comparator 1 output when c1inv=0; 1 = c1 v in + > c1 v in C 0 = c1 v in + < c1 v in C when c1inv=1; 0 = c1 v in + > c1 v in C 1 = c1 v in + < c1 v in C bit 5: c2inv : comparator 2 output inversion 1 = c2 output inverted 0 = c2 output not inverted bit 4: c1inv : comparator 1 output inversion 1 = c1 output inverted 0 = c1 output not inverted bit 3: cis : comparator input switch when cm2:cm0: = 001 : then: 1 = c1 v in C connects to ra3 0 = c1 v in C connects to ra0 when cm2:cm0 = 010 : then: 1 = c1 v in C connects to ra3 c2 v in C connects to ra2 0 = c1 v in C connects to ra0 c2 v in C connects to ra1 bit 2-0: cm2:cm0 : comparator mode figure 9-1 shows the comparator modes and cm2:cm0 bit settings.
pic16f62x ds40300b-page 58 preliminary 1999 microchip technology inc. 9.1 comparator configuration there are eight modes of operation for the comparators. the cmcon register is used to select the mode. figure 9-1 shows the eight possible modes. the trisa register controls the data direction of the comparator pins for each mode. if the comparator mode is changed, the comparator output level may not be valid for the specified mode change delay shown in table 12-2. note: comparator interrupts should be disabled during a comparator mode change other- wise a false interrupt may occur. figure 9-1: comparator i/o operating modes c1 ra0/an0 vin- vin+ ra3/an3/c10 off (read as '0') comparators reset (por default value) a a cm2:cm0 = 000 c2 ra1/an1 vin- vin+ ra2/an2 off (read as '0') a a c1 ra0/an0 vin- vin+ ra3/an3/c10 c1out two independent comparators a a cm2:cm0 = 100 c2 ra1/an1 vin- vin+ ra2/an2 c2out a a c1 ra0/an0 vin- vin+ ra3/an3/c10 c1out two common reference comparators a d cm2:cm0 = 011 c2 ra1/an1 vin- vin+ ra2/an2 c2out a a c1 ra0/an0 vin- vin+ ra3/an3/c10 off (read as '0') one independent comparator d d cm2:cm0 = 101 c2 ra1/an1 vin- vin+ ra2/an2 c2out a a c1 ra0/an0 vin- vin+ ra3/an3/c10 off (read as '0') comparators off d d cm2:cm0 = 111 c2 ra1/an1 vin- vin+ ra2/an2 off (read as '0') d d c1 ra0/an0 vin- vin+ ra3/an3/c10 c1out four inputs multiplexed to two comparators a a cm2:cm0 = 010 c2 ra1/an1 vin- vin+ ra2/an2 c2out a a from vref modul e cis = 0 cis = 1 cis = 0 cis = 1 c1 ra0/an0 vin- vin+ ra3/an3/c10 c1out two common reference comparators with outputs a d cm2:cm0 = 110 c2 ra1/an1 vin- vin+ ra2/an2 c2out a a open drain a = analog input, port reads zeros always. d = digital input. cis (cmcon<3>) is the comparator input switch. ra4/t0cki/c20 c1 ra0/an0 vin- vin+ ra3/an3/c10 c1out three inputs multiplexed to two comparators a a cm2:cm0 = 001 c2 ra1/an1 vin- vin+ ra2/an2 c2out a a cis = 0 cis = 1
1999 microchip technology inc. preliminary ds40300b-page 59 pic16f62x the code example in example 9-1 depicts the steps required to configure the comparator module. ra3 and ra4 are configured as digital output. ra0 and ra1 are configured as the v- inputs and ra2 as the v+ input to both comparators. example 9-1: initializing comparator module 9.2 comparator operation a single comparator is shown in figure 9-2 along with the relationship between the analog input levels and the digital output. when the analog input at v in + is less than the analog input v in C, the output of the comparator is a digital low level. when the analog input at v in + is greater than the analog input v in C, the output of the comparator is a digital high level. the shaded areas of the output of the comparator in figure 9-2 represent the uncertainty due to input offsets and response time. flag_reg equ 0x20 clrf flag_reg ;init flag register clrf porta ;init porta movf cmcon, w ;load comparator bits andlw 0xc0 ;mask comparator bits iorwf flag_reg,f ;store bits in flag register movlw 0x03 ;init comparator mode movwf cmcon ;cm<2:0> = 011 bsf status,rp0 ;select bank1 movlw 0x07 ;initialize data direction movwf trisa ;set ra<2:0> as inputs ;ra<4:3> as outputs ;trisa<7:5> always read 0 bcf status,rp0 ;select bank 0 call delay 10 ;10 m s delay movf cmcon,f ;read cmcon to end change condition bcf pir1,cmif ;clear pending interrupts bsf status,rp0 ;select bank 1 bsf pie1,cmie ;enable comparator interrupts bcf status,rp0 ;select bank 0 bsf intcon,peie ;enable peripheral interrupts bsf intcon,gie ;global interrupt enable 9.3 comparator reference an external or internal reference signal may be used depending on the comparator operating mode. the analog signal that is present at v in C is compared to the signal at v in +, and the digital output of the comparator is adjusted accordingly (figure 9-2). figure 9-2: single comparator 9.3.1 external reference signal when external voltage references are used, the comparator module can be configured to have the com- parators operate from the same or different reference sources. however, threshold detector applications may require the same reference. the reference signal must be between v ss and v dd , and can be applied to either pin of the comparator(s). 9.3.2 internal reference signal the comparator module also allows the selection of an internally generated voltage reference for the comparators. section 13, instruction sets, contains a detailed description of the voltage reference module that provides this signal. the internal reference signal is used when the comparators are in mode cm<2:0>=010 (figure 9-1). in this mode, the internal voltage reference is applied to the v in + pin of both comparators. C + v in + v in C output v in v in+ output
pic16f62x ds40300b-page 60 preliminary 1999 microchip technology inc. 9.4 comparator response time response time is the minimum time, after selecting a new reference voltage or input source, before the comparator output is guaranteed to have a valid level. if the internal reference is changed, the maximum delay of the internal voltage reference must be considered when using the comparator outputs. otherwise the maximum delay of the comparators should be used (table 12-2 ). 9.5 comparator outputs the comparator outputs are read through the cmcon register. these bits are read only. the comparator outputs may also be directly output to the ra3 and ra4 i/o pins. when the cm<2:0> = 110 or 001, multiplexors in the output path of the ra3 and ra4/t0ck1 pins will switch and the output of each pin will be the unsynchro- nized output of the comparator. the uncertainty of each of the comparators is related to the input offset voltage and the response time given in the specifications. figure 9-3 shows the comparator output block diagram. the trisa bits will still function as an output enable/disable for the ra3 and ra4/t0ck1 pins while in this mode. note 1: when reading the port register, all pins configured as analog inputs will read as a 0. pins configured as digital inputs will convert an analog input according to the schmitt trigger input specification. 2: analog levels on any pin that is defined as a digital input may cause the input buffer to consume more current than is specified. figure 9-3: modified comparator output block diagram d q en to ra3 or ra4/t0ck1 pin rd cmcon set cmif bit multiplex d q en cl port pins q3 * rd cmcon nreset from other comparator to data bus q1 cninv
1999 microchip technology inc. preliminary ds40300b-page 61 pic16f62x 9.6 comparator interrupts the comparator interrupt flag is set whenever there is a change in the output value of either comparator. software will need to maintain information about the status of the output bits, as read from cmcon<7:6>, to determine the actual change that has occurred. the cmif bit, pir1<6>, is the comparator interrupt flag. the cmif bit must be reset by clearing 0. since it is also possible to write a '1' to this register, a simulated interrupt may be initiated. the cmie bit (pie1<6>) and the peie bit (intcon<6>) must be set to enable the interrupt. in addition, the gie bit must also be set. if any of these bits are clear, the interrupt is not enabled, though the cmif bit will still be set if an interrupt condition occurs. the user, in the interrupt service routine, can clear the interrupt in the following manner: a) any read or write of cmcon. this will end the mismatch condition. b) clear flag bit cmif. a mismatch condition will continue to set flag bit cmif. reading cmcon will end the mismatch condition, and allow flag bit cmif to be cleared. 9.7 c omparator operation during sleep when a comparator is active and the device is placed in sleep mode, the comparator remains active and the interrupt is functional if enabled. this interrupt will note: if a change in the cmcon register (c1out or c2out) should occur when a read operation is being executed (start of the q2 cycle), then the cmif (pir1<6>) interrupt flag may not get set. wake up the device from sleep mode when enabled. while the comparator is powered-up, higher sleep currents than shown in the power down current specification will occur. each comparator that is operational will consume additional current as shown in the comparator specifications. to minimize power consumption while in sleep mode, turn off the comparators, cm<2:0> = 111, before entering sleep. if the device wakes-up from sleep, the contents of the cmcon register are not affected. 9.8 effects of a reset a device reset forces the cmcon register to its reset state. this forces the comparator module to be in the comparator reset mode, cm2:cm0 = 000. this ensures that all potential inputs are analog inputs. device current is minimized when analog inputs are present at reset time. the comparators will be powered-down during the reset interval. 9.9 analog input connection considerations a simplified circuit for an analog input is shown in figure 9-4. since the analog pins are connected to a digital output, they have reverse biased diodes to v dd and v ss . the analog input therefore, must be between v ss and v dd . if the input voltage deviates from this range by more than 0.6v in either direction, one of the diodes is forward biased and a latch-up may occur. a maximum source impedance of 10 k w is recommended for the analog sources. any external component connected to an analog input pin, such as a capacitor or a zener diode, should have very little leakage current. figure 9-4: analog input model va r s < 10k a in c pin 5 pf v dd v t = 0.6v v t = 0.6v r ic i leakage 500 na v ss legend c pin = input capacitance v t = threshold voltage i leakage = leakage current at the pin due to various junctions r ic = interconnect resistance r s = source impedance va = analog voltage
pic16f62x ds40300b-page 62 preliminary 1999 microchip technology inc. table 9-1: registers associated with comparator module legend: x = unknown, u = unchanged, - = unimplemented, read as "0" address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por value on all other resets 1fh cmcon c2out c1out c2inv c1nv cis cm2 cm1 cm0 0000 0000 0000 0000 9fh vrcon vren vroe vrr vr3 vr2 vr1 vr0 000- 0000 000- 0000 0bh/8bh/ 10bh/18bh intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000u 0ch pir1 eeif cmif rcif txif ccp1if tmr2if tmr1if 0000 -000 0000 -000 8ch pie1 eeie cmie rcie txie ccp1ie tmr2ie tmr1ie 0000 -000 0000 -000 85h trisa trisa7 trisa6 trisa4 trisa3 trisa2 trisa1 trisa0 11-1 1111 11-1 1111
pic16f62x ? 1999 microchip technology inc. preliminary ds40300b-page 63 10.0 capture/compare/pwm (ccp) module the ccp (capture/compare/pwm) module contains a 16-bit register which can operate as a 16-bit capture register, as a 16-bit compare register or as a pwm master/slave duty cycle register. table 10-1 shows the timer resources of the ccp module modes. ccp1 module capture/compare/pwm register1 (ccpr1) is com- prised of two 8-bit registers: ccpr1l (low byte) and ccpr1h (high byte). the ccp1con register controls the operation of ccp1. all are readable and writable. additional information on the ccp module is available in the picmicro? mid-range reference manual, (ds33023). table 10-1 ccp mode - timer resource register 10-1: ccp1con register (address 17h) ccp mode timer resource capture compare pwm timer1 timer1 timer2 u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ccp1x ccp1y ccp1m3 ccp1m2 ccp1m1 ccp1m0 r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por reset bit7 bit0 bit 7-6: unimplemented: read as '0' bit 5-4: ccp1x:ccp1y : pwm least significant bits capture mode: unused compare mode: unused pwm mode: these bits are the two lsbs of the pwm duty cycle. the eight msbs are found in ccprxl. bit 3-0: ccp1m3:ccp1m0 : ccpx mode select bits 0000 = capture/compare/pwm off (resets ccp1 module) 0100 = capture mode, every falling edge 0101 = capture mode, every rising edge 0110 = capture mode, every 4th rising edge 0111 = capture mode, every 16th rising edge 1000 = compare mode, set output on match (ccp1if bit is set) 1001 = compare mode, clear output on match (ccp1if bit is set) 1010 = compare mode, generate software interrupt on match (ccp1if bit is set, ccp1 pin is unaffected) 1011 = compare mode, trigger special event (ccp1if bit is set; ccp1 resets tmr1 11xx = pwm mode
pic16f62x ds40300b-page 64 preliminary ? 1999 microchip technology inc. 10.1 capture mode in capture mode, ccpr1h:ccpr1l captures the 16-bit value of the tmr1 register when an event occurs on pin rb3/ccp1. an event is defined as: ? every falling edge ? every rising edge ? every 4th rising edge ? every 16th rising edge an event is selected by control bits ccp1m3:ccp1m0 (ccp1con<3:0>). when a capture is made, the inter- rupt request flag bit ccp1if (pir1<2>) is set. it must be cleared in software. if another capture occurs before the value in register ccpr1 is read, the old captured value will be lost. 10.1.1 ccp pin configuration in capture mode, the rb3/ccp1 pin should be config- ured as an input by setting the trisb<3> bit. figure 10-1: capture mode operation block diagram 10.1.2 timer1 mode selection timer1 must be running in timer mode or synchronized counter mode for the ccp module to use the capture feature. in asynchronous counter mode, the capture operation may not work. 10.1.3 software interrupt when the capture mode is changed, a false capture interrupt may be generated. the user should keep bit ccp1ie (pie1<2>) clear to avoid false interrupts and should clear the flag bit ccp1if following any such change in operating mode. 10.1.4 ccp prescaler there are four prescaler settings, specified by bits ccp1m3:ccp1m0. whenever the ccp module is turned off, or the ccp module is not in capture mode, the prescaler counter is cleared. this means that any reset will clear the prescaler counter. switching from one capture prescaler to another may generate an interrupt. also, the prescaler counter will not be cleared, therefore the first capture may be from a non-zero prescaler. example 10-1 shows the recom- mended method for switching between capture pres- calers. this example also clears the prescaler counter and will not generate the false interrupt. example 10-1: changing between capture prescalers clrf ccp1con ;turn ccp module off movlw new_capt_ps ;load the w reg with ; the new prescaler ; mode value and ccp on movwf ccp1con ;load ccp1con with this ; value note: if the rb3/ccp1 is configured as an out- put, a write to the port can cause a capture condition. ccpr1h ccpr1l tmr1h tmr1l set flag bit ccp1if (pir1<2>) capture enable qs ccp1con<3:0> rb3/ccp1 prescaler 3 1, 4, 16 and edge detect pin
pic16f62x ? 1999 microchip technology inc. preliminary ds40300b-page 65 10.2 compare mode in compare mode, the 16-bit ccpr1 register value is constantly compared against the tmr1 register pair value. when a match occurs, the rb3/ccp1 pin is: ? driven high ? driven low ? remains unchanged the action on the pin is based on the value of control bits ccp1m3:ccp1m0 (ccp1con<3:0>). at the same time, interrupt flag bit ccp1if is set. figure 10-2: compare mode operation block diagram 10.2.1 ccp pin configuration the user must configure the rb3/ccp1 pin as an out- put by clearing the trisb<3> bit. 10.2.2 timer1 mode selection timer1 must be running in timer mode or synchro- nized counter mode if the ccp module is using the compare feature. in asynchronous counter mode, the compare operation may not work. 10.2.3 software interrupt mode when generate software interrupt is chosen the ccp1 pin is not affected. only a ccp interrupt is generated (if enabled). 10.2.4 special event trigger in this mode, an internal hardware trigger is generated which may be used to initiate an action. the special event trigger output of ccp1 resets the tmr1 register pair. this allows the ccpr1 register to effectively be a 16-bit programmable period register for timer1. table 10-2 registers associated with capture, compare, and timer1 ccpr1h ccpr1l tmr1h tmr1l comparator qs r output logic special event trigger (ccp2 only) set flag bit ccp1if (pir1<2>) match rb3/ccp1 trisb<3> ccp1con<3:0> mode select output enable pin special event trigger will reset timer1, but not set interrupt flag bit tmr1if (pir1<0>) note: clearing the ccp1con register will force the rb3/ccp1 compare output latch to the default low level. this is not the data latch. address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por value on all other resets 0bh/8bh/1 0bh/18bh intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000u 0ch pir1 eeif cmif rcif txif ccp1if tmr2if tmr1if 0000 -000 0000 -000 8ch pie1 eeie cmif rcie txie ccp1ie tmr2ie tmr1ie 0000 -000 0000 -000 87h trisb portb data direction register 1111 1111 1111 1111 0eh tmr1l holding register for the least significant byte of the 16-bit tmr1 register xxxx xxxx uuuu uuuu 0fh tmr1h holding register for the most significant byte of the 16-bit tmr1register xxxx xxxx uuuu uuuu 10h t1con t1ckps1 t1ckps0 t1oscen t1sync tmr1cs tmr1on --00 0000 --uu uuuu 15h ccpr1l capture/compare/pwm register1 (lsb) xxxx xxxx uuuu uuuu 16h ccpr1h capture/compare/pwm register1 (msb) xxxx xxxx uuuu uuuu 17h ccp1con ccp1x ccp1y ccp1m3 ccp1m2 ccp1m1 ccp1m0 --00 0000 --00 0000 legend: x = unknown, u = unchanged, - = unimplemented read as '0'. shaded cells are not used by capture and timer1.
pic16f62x ds40300b-page 66 preliminary ? 1999 microchip technology inc. 10.3 pwm mode in pulse width modulation (pwm) mode, the ccp1 pin produces up to a 10-bit resolution pwm output. since the ccp1 pin is multiplexed with the portc data latch, the trisb<3> bit must be cleared to make the ccp1 pin an output. figure 10-3 shows a simplified block diagram of the ccp module in pwm mode. for a step by step procedure on how to set up the ccp module for pwm operation, see section 10.3.3 . figure 10-3: simplified pwm block diagram a pwm output ( figure 10-4 ) has a time base (period) and a time that the output stays high (duty cycle). the frequency of the pwm is the inverse of the period (1/period). figure 10-4: pwm output 10.3.1 pwm period the pwm period is specified by writing to the pr2 reg- ister. the pwm period can be calculated using the fol- lowing formula: pwm period = [(pr2) + 1] ? 4 ? t osc ? (tmr2 prescale value) pwm frequency is defined as 1 / [pwm period]. when tmr2 is equal to pr2, the following three events occur on the next increment cycle: ? tmr2 is cleared ? the ccp1 pin is set (exception: if pwm duty cycle = 0%, the ccp1 pin will not be set) ? the pwm duty cycle is latched from ccpr1l into ccpr1h 10.3.2 pwm duty cycle the pwm duty cycle is specified by writing to the ccpr1l register and to the ccp1con<5:4> bits. up to 10-bit resolution is available: the ccpr1l contains the eight msbs and the ccp1con<5:4> contains the two lsbs. this 10-bit value is represented by ccpr1l:ccp1con<5:4>. the following equation is used to calculate the pwm duty cycle in time: pwm duty cycle = (ccpr1l:ccp1con<5:4>) ? tosc ? (tmr2 prescale value) ccpr1l and ccp1con<5:4> can be written to at any time, but the duty cycle value is not latched into ccpr1h until after a match between pr2 and tmr2 occurs (i.e., the period is complete). in pwm mode, ccpr1h is a read-only register. the ccpr1h register and a 2-bit internal latch are used to double buffer the pwm duty cycle. this double buffering is essential for glitchless pwm operation. when the ccpr1h and 2-bit latch match tmr2 con- catenated with an internal 2-bit q clock or 2 bits of the tmr2 prescaler, the ccp1 pin is cleared. maximum pwm resolution (bits) for a given pwm frequency: for an example pwm period and duty cycle calcula- tion, see the picmicro? mid-range reference manual (ds33023). note: clearing the ccp1con register will force the ccp1 pwm output latch to the default low level. this is not the portb i/o data latch. ccpr1l ccpr1h (slave) comparator tmr2 comparator pr2 (note 1) r q s duty cycle registers ccp1con<5:4> clear timer, ccp1 pin and latch d.c. trisb<3> rb3/ccp1 note 1: 8-bit timer is concatenated with 2-bit internal q clock or 2 bits of the prescaler to create 10-bit time-base. period duty cycle tmr2 = pr2 tmr2 = duty cycle tmr2 = pr2 note: the timer2 postscaler (see section 8.0 ) is not used in the determination of the pwm frequency. the postscaler could be used to have a servo update rate at a different fre- quency than the pwm output. note: if the pwm duty cycle value is longer than the pwm period the ccp1 pin will not be cleared. log ( fpwm log (2) fosc ) bits =
pic16f62x ? 1999 microchip technology inc. preliminary ds40300b-page 67 10.3.3 set-up for pwm operation the following steps should be taken when configuring the ccp module for pwm operation: 1. set the pwm period by writing to the pr2 regis- ter. 2. set the pwm duty cycle by writing to the ccpr1l register and ccp1con<5:4> bits. 3. make the ccp1 pin an output by clearing the trisb<3> bit. 4. set the tmr2 prescale value and enable timer2 by writing to t2con. 5. configure the ccp1 module for pwm operation. table 10-3 example pwm frequencies and resolutions at 20 mhz table 10-4 registers associated with pwm and timer2 pwm frequency 1.22 khz 4.88 khz 19.53 khz 78.12 khz 156.3 khz 208.3 khz timer prescaler (1, 4, 16) 16 4 1 1 1 1 pr2 value 0xff 0xff 0xff 0x3f 0x1f 0x17 maximum resolution (bits) 10 10 10 8 7 5.5 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por value on all other resets 0bh/8bh/ 10bh/18bh intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000u 0ch pir1 eeif cmif rcif txif ccp1if tmr2if tmr1if 0000 -000 0000 -000 8ch pie1 eeie cmie rcie txie ccp1ie tmr2ie tmr1ie 0000 -000 0000 -000 87h trisb portb data direction register 1111 1111 1111 1111 11h tmr2 timer2 modules register 0000 0000 0000 0000 92h pr2 timer2 modules period register 1111 1111 1111 1111 12h t2con toutps 3 toutps 2 toutps 1 toutps 0 tmr2on t2ckps 1 t2ckps 0 -000 0000 uuuu uuuu 15h ccpr1l capture/compare/pwm register1 (lsb) xxxx xxxx uuuu uuuu 16h ccpr1h capture/compare/pwm register1 (msb) xxxx xxxx uuuu uuuu 17h ccp1con ccp1x ccp1y ccp1m3 ccp1m2 ccp1m1 ccp1m0 --00 0000 --00 0000 legend: x = unknown, u = unchanged, - = unimplemented read as '0'. shaded cells are not used by pwm and timer2.
pic16f62x ds40300b-page 68 preliminary ? 1999 microchip technology inc. notes:
1999 microchip technology inc. preliminary ds40300b-page 69 pic16f62x 11.0 voltage reference module the voltage reference is a 16-tap resistor ladder network that provides a selectable voltage reference. the resistor ladder is segmented to provide two ranges of v ref values and has a power-down function to conserve power when the reference is not being used. the vrcon register controls the operation of the reference as shown in figure 11-1. the block diagram is given in figure 11-2. 11.1 configuring the voltage reference the voltage reference can output 16 distinct voltage levels for each range. the equations used to calculate the output of the voltage reference are as follows: if v rr = 1: v ref = (v r <3:0>/24) x v dd if v rr = 0: v ref = (v dd x 1/4) + (v r <3:0>/32) x v dd the setting time of the voltage reference must be considered when changing the v ref output (table 12-2). example 11-1 shows an example of how to configure the voltage reference for an output volt- age of 1.25v with v dd = 5.0v. figure 11-1: vrcon register(address 9fh) figure 11-2: voltage reference block diagram r/w-0 r/w-0 r/w-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 v ren v roe v rr v r3 v r2 v r1 v r0 r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por reset bit7 bit0 bit 7: v ren : v ref enable 1 = v ref circuit powered on 0 = v ref circuit powered down, no i dd drain bit 6: v roe : v ref output enable 1 = v ref is output on ra2 pin 0 = v ref is disconnected from ra2 pin bit 5: v rr : v ref range selection 1 = low range 0 = high range bit 4: unimplemented: read as '0' bit 3-0: v r <3:0> : v ref value selection 0 v r [3:0] 15 when v rr = 1: v ref = (v r <3:0>/ 24) * v dd when v rr = 0: v ref = 1/4 * v dd + (v r <3:0>/ 32) * v dd note: r is defined in table 12-3. v rr 8r v r 3 v r 0 (from vrcon<3:0>) 16-1 analog mux 8r r r r r v ren v ref 16 stages
pic16f62x ds40300b-page 70 preliminary 1999 microchip technology inc. example 11-1: voltage reference configuration 11.2 voltage reference accuracy/error the full range of v ss to v dd cannot be realized due to the construction of the module. the transistors on the top and bottom of the resistor ladder network (figure 11-2) keep v ref from approaching v ss or v dd . the voltage reference is v dd derived and therefore, the v ref output changes with fluctuations in v dd . the tested absolute accuracy of the voltage reference can be found in table 17-2. 11.3 operation during sleep when the device wakes up from sleep through an interrupt or a watchdog timer time-out, the contents of the vrcon register are not affected. to minimize current consumption in sleep mode, the voltage reference should be disabled. movlw 0x02 ; 4 inputs muxed movwf cmcon ; to 2 comps. bsf status,rp0 ; go to bank 1 movlw 0x07 ; ra3-ra0 are movwf trisa ; outputs movlw 0xa6 ; enable v ref movwf vrcon ; low range ; set v r <3:0>=6 bcf status,rp0 ; go to bank 0 call delay10 ; 10 m s delay 11.4 effects of a reset a device reset disables the voltage reference by clear- ing bit v ren (vrcon<7>). this reset also disconnects the reference from the ra2 pin by clearing bit v roe (vrcon<6>) and selects the high voltage range by clearing bit v rr (vrcon<5>). the v ref value select bits, vrcon<3:0>, are also cleared. 11.5 connection considerations the voltage reference module operates independently of the comparator module. the output of the reference generator may be connected to the ra2 pin if the trisa<2> bit is set and the v roe bit, vrcon<6>, is set. enabling the voltage reference output onto the ra2 pin with an input signal present will increase current consumption. connecting ra2 as a digital output with v ref enabled will also increase current consumption. the ra2 pin can be used as a simple d/a output with limited drive capability. due to the limited drive capability, a buffer must be used in conjunction with the voltage reference output for external connections to v ref . figure 11-3 shows an example buffering technique. figure 11-3: voltage reference output buffer example table 11-1: registers associated with voltage reference note: - = unimplemented, read as "0" address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por value on all other resets 9fh vrcon vren vroe vrr vr3 vr2 vr1 vr0 000- 0000 000- 0000 1fh cmcon c2out c1out c2inv c1inv cis cm2 cm1 cm0 0000 0000 0000 0000 85h trisa trisa7 trisa6 trisa4 trisa3 trisa2 trisa1 trisa0 11-1 1111 11-1 1111 v ref output + C ? ? v ref module voltage reference output impedance r (1) ra2 note 1: r is dependent upon the voltage reference configuration vrcon<3:0> and vrcon<5>.
1999 microchip technology inc. preliminary ds40300b-page 71 pic16f62x 12.0 universal synchronous asynchronous receiver transmitter (usart) the universal synchronous asynchronous receiver transmitter (usart) module is one of the two serial i/o modules. (usart is also known as a serial com- munications interface or sci). the usart can be con- figured as a full duplex asynchronous system that can communicate with peripheral devices such as crt ter- minals and personal computers, or it can be configured as a half duplex synchronous system that can commu- nicate with peripheral devices such as a/d or d/a inte- grated circuits, serial eeproms etc. the usart can be configured in the following modes: ? asynchronous (full duplex) ? synchronous - master (half duplex) ? synchronous - slave (half duplex) bit spen (rcsta<7>), and bits trisb<2:1>, have to be set in order to configure pins rb2/tx/ck and rb1/rx/dt as the universal synchronous asyn- chronous receiver transmitter. register 12-1: txsta: transmit status and control register (address 98h) r/w-0 r/w-0 r/w-0 r/w-0 u-0 r/w-0 r-1 r/w-0 csrc tx9 txen sync brgh trmt tx9d r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por reset bit7 bit0 bit 7: csrc : clock source select bit asynchronous mode dont care synchronous mode 1 = master mode (clock generated internally from brg) 0 = slave mode (clock from external source) bit 6: tx9 : 9-bit transmit enable bit 1 = selects 9-bit transmission 0 = selects 8-bit transmission bit 5: txen : transmit enable bit 1 = transmit enabled 0 = transmit disabled note: sren/cren overrides txen in sync mode. bit 4: sync : usart mode select bit 1 = synchronous mode 0 = asynchronous mode bit 3: unimplemented: read as '0' bit 2: brgh : high baud rate select bit asynchronous mode 1 = high speed 0 = low speed synchronous mode unused in this mode bit 1: trmt : transmit shift register status bit 1 = tsr empty 0 = tsr full bit 0: tx9d : 9th bit of transmit data. can be parity bit.
pic16f62x ds40300b-page 72 preliminary 1999 microchip technology inc. register 12-2: rcsta: receive status and control register (address 18h) r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r-0 r-0 r-x spen rx9 sren cren aden ferr oerr rx9d r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por reset x = unknown bit7 bit0 bit 7: spen : serial port enable bit (configures rb1/rx/dt and rb2/tx/ck pins as serial port pins when bits trisb<2:17> are set) 1 = serial port enabled 0 = serial port disabled bit 6: rx9 : 9-bit receive enable bit 1 = selects 9-bit reception 0 = selects 8-bit reception bit 5: sren : single receive enable bit asynchronous mode: dont care synchronous mode - master: 1 = enables single receive 0 = disables single receive this bit is cleared after reception is complete. synchronous mode - slave: unused in this mode bit 4: cren : continuous receive enable bit asynchronous mode: 1 = enables continuous receive 0 = disables continuous receive synchronous mode: 1 = enables continuous receive until enable bit cren is cleared (cren overrides sren) 0 = disables continuous receive bit 3: aden: address detect enable bit asynchronous mode 9-bit (rx9 = 1): 1 = enables address detection, enable interrupt and load of the receive buffer when rsr<8> is set 0 = disables address detection, all bytes are received, and ninth bit can be used as parity bit asynchronous mode 8-bit (rx9=0): unused in this mode synchronous mode unused in this mode bit 2: ferr : framing error bit 1 = framing error (can be updated by reading rcreg register and receive next valid byte) 0 = no framing error bit 1: oerr : overrun error bit 1 = overrun error (can be cleared by clearing bit cren) 0 = no overrun error bit 0: rx9d : 9th bit of received data (can be parity bit)
1999 microchip technology inc. preliminary ds40300b-page 73 pic16f62x 12.1 u sart baud rate generator (brg) the brg supports both the asynchronous and syn- chronous modes of the usart. it is a dedicated 8-bit baud rate generator. the spbrg register controls the period of a free running 8-bit timer. in asynchronous mode bit brgh (txsta<2>) also controls the baud rate. in synchronous mode bit brgh is ignored. table 12-1 shows the formula for computation of the baud rate for different usart modes which only apply in master mode (internal clock). given the desired baud rate and fosc, the nearest inte- ger value for the spbrg register can be calculated using the formula in table 12-1. from this, the error in baud rate can be determined. example 12-1 shows the calculation of the baud rate error for the following conditions: f osc = 16 mhz desired baud rate = 9600 brgh = 0 sync = 0 example 12-1: calculating baud rate error it may be advantageous to use the high baud rate (brgh = 1) even for slower baud clocks. this is because the f osc /(16(x + 1)) equation can reduce the baud rate error in some cases. writing a new value to the spbrg register, causes the brg timer to be reset (or cleared), this ensures the brg does not wait for a timer overflow before output- ting the new baud rate. desired baud rate = fosc / (64 (x + 1)) 9600 = 16000000 /(64 (x + 1)) x= ?25.042 = 25 calculated baud rate=16000000 / (64 (25 + 1)) = 9615 error = (calculated baud rate - desired baud rate) desired baud rate = (9615 - 9600) / 9600 = 0.16% table 12-1: baud rate formula table 12-2: registers associated with baud rate generator sync brgh = 0 (low speed) brgh = 1 (high speed) 0 1 (asynchronous) baud rate = f osc /(64(x+1)) (synchronous) baud rate = f osc /(4(x+1)) baud rate= f osc /(16(x+1)) na x = value in spbrg (0 to 255) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por value on all other resets 98h txsta csrc tx9 txen sync brgh trmt tx9d 0000 -010 0000 -010 18h rcsta spen rx9 sren cren aden ferr oerr rx9d 0000 -00x 0000 -00x 99h spbrg baud rate generator register 0000 0000 0000 0000 legend: x = unknown, - = unimplemented read as '0'. shaded cells are not used by the brg.
pic16f62x ds40300b-page 74 preliminary 1999 microchip technology inc. table 12-3: baud rates for synchronous mode table 12-4: baud rates for asynchronous mode (brgh = 0) baud rate (k) f osc = 20 mhz spbrg value (decimal) 16 mhz spbrg value (decimal) 10 mhz spbrg value (decimal) 7.15909 mhz spbrg value (decimal) kbaud % error kbaud % error kbaud % error kbaud % error 0.3na - -na - -na - -na - - 1.2na - -na - -na - -na - - 2.4na - -na - -na - -na - - 9.6 na - - na - - 9.766 +1.73 255 9.622 +0.23 185 19.2 19.53 +1.73 255 19.23 +0.16 207 19.23 +0.16 129 19.24 +0.23 92 76.8 76.92 +0.16 64 76.92 +0.16 51 75.76 -1.36 32 77.82 +1.32 22 96 96.15 +0.16 51 95.24 -0.79 41 96.15 +0.16 25 94.20 -1.88 18 300 294.1 -1.96 16 307.69 +2.56 12 312.5 +4.17 7 298.3 -0.57 5 500 500 0 9 500 0 7 500 0 4 na - - high 5000 - 0 4000 - 0 2500 - 0 1789.8 - 0 low 19.53 - 255 15.625 - 255 9.766 - 255 6.991 - 255 baud rate (k) f osc = 5.0688 mhz 4 mhz spbrg value (decimal) 3.579545 mhz spbrg value (decimal) 1 mhz spbrg value (decimal) 32.768 khz spbrg value (decimal) kbaud % error spbrg value (decimal) kbaud % error kbaud % error kbaud % error kbaud % error 0.3na- -na- - na- -na- -0.303+1.1426 1.2 na - - na - - na - - 1.202 +0.16 207 1.170 -2.48 6 2.4 na - - na - - na - - 2.404 +0.16 103 na - - 9.6 9.6 0 131 9.615 +0.16 103 9.622 +0.23 92 9.615 +0.16 25 na - - 19.2 19.2 0 65 19.231 +0.16 51 19.04 -0.83 46 19.24 +0.16 12 na - - 76.8 79.2 +3.13 15 76.923 +0.16 12 74.57 -2.90 11 83.34 +8.51 2 na - - 96 97.48 +1.54 12 1000 +4.17 9 99.43 +3.57 8 na - - na - - 300 316.8 +5.60 3 na - - 298.3 -0.57 2 na - - na - - 500na- -na- - na- -na- -na- - high 1267 - 0 100 - 0 894.9 - 0 250 - 0 8.192 - 0 low 4.950 - 255 3.906 - 255 3.496 - 255 0.9766 - 255 0.032 - 255 baud rate (k) f osc = 20 mhz spbrg value (decimal) 16 mhz spbrg value (decimal) 10 mhz spbrg value (decimal) 7.15909 mhz spbrg value (decimal) kbaud % error kbaud % error kbaud % error kbaud % error 0.3na--na --na --na-- 1.2 1.221 +1.73 255 1.202 +0.16 207 1.202 +0.16 129 1.203 +0.23 92 2.4 2.404 +0.16 129 2.404 +0.16 103 2.404 +0.16 64 2.380 -0.83 46 9.6 9.469 -1.36 32 9.615 +0.16 25 9.766 +1.73 15 9.322 -2.90 11 19.2 19.53 +1.73 15 19.23 +0.16 12 19.53 +1.73 7 18.64 -2.90 5 76.8 78.13 +1.73 3 83.33 +8.51 2 78.13 +1.73 1 na - - 96 104.2 +8.51 2 na - - na - - na - - 300 312.5 +4.17 0 na - - na - - na - - 500na - -na - -na - -na - - high 312.5 - 0 250 - 0 156.3 - 0 111.9 - 0 low 1.221 - 255 0.977 - 255 0.6104 - 255 0.437 - 255 baud rate (k) f osc = 5.0688 mhz 4 mhz spbrg value (decimal) 3.579545 mhz spbrg value (decimal) 1 mhz spbrg value (decimal) 32.768 khz spbrg value (decimal) kbaud % error spbrg value (decimal) kbaud % error kbaud % error kbaud % error kbaud % error 0.3 0.31 +3.13 255 0.3005 -0.17 207 0.301 +0.23 185 0.300 +0.16 51 0.256 -14.67 1 1.2 1.2 0 65 1.202 +1.67 51 1.190 -0.83 46 1.202 +0.16 12 na - - 2.4 2.4 0 32 2.404 +1.67 25 2.432 +1.32 22 2.232 -6.99 6 na - - 9.6 9.9 +3.13 7 na - - 9.322 -2.90 5 na - - na - - 19.2 19.8 +3.13 3 na - - 18.64 -2.90 2 na - - na - - 76.8 79.2 +3.13 0 na - - na - - na - - na - - 96na--na--na--na--na-- 300na- -na- -na- -na- -na- - 500na- -na- -na- -na- -na- - high 79.2 - 0 62.500 - 0 55.93 - 0 15.63 - 0 0.512 - 0 low 0.3094 - 255 3.906 - 255 0.2185 - 255 0.0610 - 255 0.0020 - 255
1999 microchip technology inc. preliminary ds40300b-page 75 pic16f62x table 12-5: baud rates for asynchronous mode (brgh = 1) baud rate (k) f osc = 20 mhz spbrg value (decimal) 16 mhz spbrg value (decimal) 10 mhz spbrg value (decimal) 7.16 mhz spbrg value (decimal) kbaud % error kbaud % error kbaud % error kbaud % error 9.6 9.615 +0.16 129 9.615 +0.16 103 9.615 +0.16 64 9.520 -0.83 46 19.2 19.230 +0.16 64 19.230 +0.16 51 18.939 -1.36 32 19.454 +1.32 22 38.4 37.878 -1.36 32 38.461 +0.16 25 39.062 +1.7 15 37.286 -2.90 11 57.6 56.818 -1.36 21 58.823 +2.12 16 56.818 -1.36 10 55.930 -2.90 7 115.2 113.636 -1.36 10 111.111 -3.55 8 125 +8.51 4 111.860 -2.90 3 250 250 0 4 250 0 3 na - - na - - 625 625 0 1 na - - 625 0 0 na - - 1250 1250 0 0 na - - na - - na - - baud rate (k) f osc = 5.068 mhz spbrg value (decimal) 4 mhz spbrg value (decimal) 3.579 mhz spbrg value (decimal) 1 mhz spbrg value (decimal) 32.768 khz spbrg value (decimal) kbaud % error kbaud % error kbaud % error kbaud % error kbaud % error 9.6 9.6 0 32 na - - 9.727 +1.32 22 8.928 -6.99 6 na - - 19.2 18.645 -2.94 16 1.202 +0.17 207 18.643 -2.90 11 20.833 +8.51 2 na - - 38.4 39.6 +3.12 7 2.403 +0.13 103 37.286 -2.90 5 31.25 -18.61 1 na - - 57.6 52.8 -8.33 5 9.615 +0.16 25 55.930 -2.90 3 62.5 +8.51 0 na - - 115.2 105.6 -8.33 2 19.231 +0.16 12 111.860 -2.90 1 na - - na - - 250 na - - na - - 223.721 -10.51 0 na - - na - - 625na - -na- -na- -na- -na- - 1250 na - - na - - na - - na - - na - -
pic16f62x ds40300b-page 76 preliminary 1999 microchip technology inc. 12.1.1 sampling the data on the rb1/rx/dt pin is sampled three times by a majority detect circuit to determine if a high or a low level is present at the rx pin. if bit brgh (txsta<2>) is clear (i.e., at the low baud rates), the sampling is done on the seventh, eighth and ninth fall- ing edges of a x16 clock (figure 12-3). if bit brgh is set (i.e., at the high baud rates), the sampling is done on the 3 clock edges preceding the second rising edge after the first falling edge of a x4 clock (figure 12-4 and figure 12-5). figure 12-1: rx pin sampling scheme. brgh = 0 figure 12-2: rx pin sampling scheme, brgh = 1 rx baud clk x16 clk start bit bit0 samples 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 2 3 baud clk for all but start bit (rb1/rx/dt pin) rx pin baud clk x4 clk q2, q4 clk start bit bit0 bit1 first falling edge after rx pin goes low second rising edge samples samples samples 1234123412
1999 microchip technology inc. preliminary ds40300b-page 77 pic16f62x figure 12-3: rx pin sampling scheme, brgh = 1 figure 12-4: rx pin sampling scheme, brgh = 0 or brgh = 1 rx pin baud clk x4 clk q2, q4 clk start bit bit0 first falling edge after rx pin goes low second rising edge samples 12 3 4 baud clk for all but start bit rx baud clk x16 clk start bit bit0 samples 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 2 3 baud clk for all but start bit (rb1/rx/dt pin)
pic16f62x ds40300b-page 78 preliminary 1999 microchip technology inc. 12.2 usart asynchronous mode in this mode, the usart uses standard nonreturn-to- zero (nrz) format (one start bit, eight or nine data bits and one stop bit). the most common data format is 8-bits. an on-chip dedicated 8-bit baud rate generator can be used to derive standard baud rate frequencies from the oscillator. the usart transmits and receives the lsb first. the usarts transmitter and receiver are functionally independent but use the same data format and baud rate. the baud rate generator produces a clock either x16 or x64 of the bit shift rate, depending on bit brgh (txsta<2>). parity is not supported by the hardware, but can be implemented in software (and stored as the ninth data bit). asynchronous mode is stopped during sleep. asynchronous mode is selected by clearing bit sync (txsta<4>). the usart asynchronous module consists of the fol- lowing important elements: ? baud rate generator ? sampling circuit ? asynchronous transmitter ? asynchronous receiver 12.2.1 usart asynchronous transmitter the usart transmitter block diagram is shown in figure 12-5. the heart of the transmitter is the transmit (serial) shift register (tsr). the shift register obtains its data from the read/write transmit buffer, txreg. the txreg register is loaded with data in software. the tsr register is not loaded until the stop bit has been transmitted from the previous load. as soon as the stop bit is transmitted, the tsr is loaded with new data from the txreg register (if available). once the txreg register transfers the data to the tsr register (occurs in one t cy ), the txreg register is empty and flag bit txif (pir1<4>) is set. this interrupt can be enabled/disabled by setting/clearing enable bit txie ( pie1<4>). flag bit txif will be set regardless of the state of enable bit txie and cannot be cleared in soft- ware. it will reset only when new data is loaded into the txreg register. while flag bit txif indicated the sta- tus of the txreg register, another bit trmt (txsta<1>) shows the status of the tsr register. sta- tus bit trmt is a read only bit which is set when the tsr register is empty. no interrupt logic is tied to this bit, so the user has to poll this bit in order to determine if the tsr register is empty. transmission is enabled by setting enable bit txen (txsta<5>). the actual transmission will not occur until the txreg register has been loaded with data and the baud rate generator (brg) has produced a shift clock (figure 12-5). the transmission can also be started by first loading the txreg register and then setting enable bit txen. normally when transmission is first started, the tsr register is empty, so a transfer to the txreg register will result in an immediate trans- fer to tsr resulting in an empty txreg. a back-to- back transfer is thus possible (figure 12-7). clearing enable bit txen during a transmission will cause the transmission to be aborted and will reset the transmit- ter. as a result the rb2/tx/ck pin will revert to hi- impedance. in order to select 9-bit transmission, transmit bit tx9 (txsta<6>) should be set and the ninth bit should be written to tx9d (txsta<0>). the ninth bit must be written before writing the 8-bit data to the txreg reg- ister. this is because a data write to the txreg regis- ter can result in an immediate transfer of the data to the tsr register (if the tsr is empty). in such a case, an incorrect ninth data bit maybe loaded in the tsr regis- ter. note 1: the tsr register is not mapped in data memory so it is not available to the user. note 2: flag bit txif is set when enable bit txen is set. figure 12-5: usart transmit block diagram txif txie interrupt txen baud rate clk spbrg baud rate generator tx9d msb lsb data bus txreg register tsr register (8) 0 tx9 trmt spen rb2/tx/ck pin pin buffer and control 8
1999 microchip technology inc. preliminary ds40300b-page 79 pic16f62x steps to follow when setting up an asynchronous transmission: 1. initialize the spbrg register for the appropriate baud rate. if a high speed baud rate is desired, set bit brgh. (section 12.1) 2. enable the asynchronous serial port by clearing bit sync and setting bit spen. 3. if interrupts are desired, then set enable bit txie. 4. if 9-bit transmission is desired, then set transmit bit tx9. 5. enable the transmission by setting bit txen, which will also set bit txif. 6. if 9-bit transmission is selected, the ninth bit should be loaded in bit tx9d. 7. load data to the txreg register (starts trans- mission). figure 12-6: asynchronous master transmission figure 12-7: asynchronous master transmission (back to back) table 12-6: registers associated with asynchronous transmission address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por value on all other resets 0ch pir1 eeif cmif rcif txif ccp1if tmr2if tmr1if 0000 -000 0000 -000 18h rcsta spen rx9 sren cren aden ferr oerr rx9d 0000 -00x 0000 -00x 19h txreg usart transmit register 0000 0000 0000 0000 8ch pie1 eeie cmie rcie txie ccp1ie tmr2ie tmr1ie 0000 -000 0000 -000 98h txsta csrc tx9 txen sync brgh trmt tx9d 0000 -010 0000 -010 99h spbrg baud rate generator register 0000 0000 0000 0000 legend: x = unknown, - = unimplemented locations read as '0'. shaded cells are not used for asynchronous transmission. word 1 stop bit word 1 transmit shift reg start bit bit 0 bit 1 bit 7/8 write to txreg word 1 brg output (shift clock) rb2/tx/ck (pin) txif bit (transmit buffer reg. empty flag) trmt bit (transmit shift reg. empty flag) transmit shift reg. write to txreg brg output (shift clock) rb2/tx/ck (pin) txif bit (interrupt reg. flag) trmt bit (transmit shift reg. empty flag) word 1 word 2 word 1 word 2 start bit stop bit start bit transmit shift reg. word 1 word 2 bit 0 bit 1 bit 7/8 bit 0 note: this timing diagram shows two consecutive transmissions.
pic16f62x ds40300b-page 80 preliminary 1999 microchip technology inc. 12.2.2 usart asynchronous receiver the receiver block diagram is shown in figure 12-8. the data is received on the rb1/rx/dt pin and drives the data recovery block. the data recovery block is actually a high speed shifter operating at x16 times the baud rate, whereas the main receive serial shifter oper- ates at the bit rate or at f osc . once asynchronous mode is selected, reception is enabled by setting bit cren (rcsta<4>). the heart of the receiver is the receive (serial) shift reg- ister (rsr). after sampling the stop bit, the received data in the rsr is transferred to the rcreg register (if it is empty). if the transfer is complete, flag bit rcif (pir1<5>) is set. the actual interrupt can be enabled/ disabled by setting/clearing enable bit rcie (pie1<5>). flag bit rcif is a read only bit which is cleared by the hardware. it is cleared when the rcreg register has been read and is empty. the rcreg is a double buff- ered register, i.e. it is a two deep fifo. it is possible for two bytes of data to be received and transferred to the rcreg fifo and a third byte begin shifting to the rsr register. on the detection of the stop bit of the third byte, if the rcreg register is still full then overrun error bit oerr (rcsta<1>) will be set. the word in the rsr will be lost. the rcreg register can be read twice to retrieve the two bytes in the fifo. overrun bit oerr has to be cleared in software. this is done by resetting the receive logic (cren is cleared and then set). if bit oerr is set, transfers from the rsr register to the rcreg register are inhibited, so it is essential to clear error bit oerr if it is set. framing error bit ferr (rcsta<2>) is set if a stop bit is detected as clear. bit ferr and the 9th receive bit are buffered the same way as the receive data. reading the rcreg, will load bits rx9d and ferr with new values, therefore it is essential for the user to read the rcsta register before reading rcreg register in order not to lose the old ferr and rx9d information. figure 12-8: usart receive block diagram x64 baud rate clk spbrg baud rate generator rb1/rx/dt pin buffer and control spen data recovery cren oerr ferr rsr register msb lsb rx9d rcreg register fifo interrupt rcif rcie data bus 8 ? 64 ? 16 or stop start (8) 7 1 0 rx9 rx9 aden rx9 aden rsr<8> enable load of receive buffer 8 8 rcreg register rx9d
1999 microchip technology inc. preliminary ds40300b-page 81 pic16f62x figure 12-9: asynchronous reception with address detect figure 12-10: asynchronous reception with address byte first figure 12-11: asynchronous reception with address byte first followed by valid data byte start bit bit1 bit0 bit8 bit0 stop bit start bit bit8 stop bit rc7/rx/dt (pin) rcv buffer reg rcv shift reg read rcv buffer reg rcreg rcif (interrupt flag) word 1 rcreg note: this timing diagram shows a data byte followed by an address byte. the data byte is not read into the rcreg (receive buffer) bit8 = 0, data byte bit8 = 1, address byte because aden = 1 and bit8 = 0. aden = 1 (address match enable) '1' '1' start bit bit1 bit0 bit8 bit0 stop bit start bit bit8 stop bit rc7/rx/dt (pin) reg rcv buffer reg rcv shift read rcv buffer reg rcreg rcif (interrupt flag) word 1 rcreg bit8 = 1, address byte bit8 = 0, data byte note: this timing diagram shows an address byte followed by an data byte. the data byte is not read into the rcreg (receive buffer ) because aden was not updated (still = 1) and bit8 = 0. aden = 1 (address match enable) '1' '1' start bit bit1 bit0 bit8 bit0 stop bit start bit bit8 stop bit rc7/rx/dt (pin) reg rcv buffer reg rcv shift read rcv buffer reg rcreg rcif (interrupt flag) word 2 rcreg bit8 = 1, address byte bit8 = 0, data byte note: this timing diagram shows an address byte followed by an data byte. the data byte is read into the rcreg (receive buffer) because aden was updated after an address match, and was cleared to a 0, so the contents of the receive shift register (rsr) are read into the receive buffer regardless of the value of bit8. aden (address match enable) word 1 rcreg
pic16f62x ds40300b-page 82 preliminary 1999 microchip technology inc. steps to follow when setting up an asynchronous reception: 1. initialize the spbrg register for the appropriate baud rate. if a high speed baud rate is desired, set bit brgh. (section 12.1). 2. enable the asynchronous serial port by clearing bit sync, and setting bit spen. 3. if interrupts are desired, then set enable bit rcie. 4. if 9-bit reception is desired, then set bit rx9. 5. enable the reception by setting bit cren. 6. flag bit rcif will be set when reception is com- plete and an interrupt will be generated if enable bit rcie was set. 7. read the rcsta register to get the ninth bit (if enabled) and determine if any error occurred during reception. 8. read the 8-bit received data by reading the rcreg register. 9. if any error occurred, clear the error by clearing enable bit cren. table 12-7: registers associated with asynchronous reception address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por value on all other resets 0ch pir1 eeif cmif rcif txif ccp1if tmr2if tmr1if 0000 -000 0000 -000 18h rcsta spen rx9 sren cren aden ferr oerr rx9d 0000 -00x 0000 -00x 1ah rcreg usart receive register 0000 0000 0000 0000 8ch pie1 eeie cmie rcie txie ccp1ie tmr2ie tmr1ie 0000 -000 0000 -000 98h txsta csrc tx9 txen sync brgh trmt tx9d 0000 -010 0000 -010 99h spbrg baud rate generator register 0000 0000 0000 0000 legend: x = unknown, - = unimplemented locations read as '0'. shaded cells are not used for asynchronous reception.
1999 microchip technology inc. preliminary ds40300b-page 83 pic16f62x 12.3 usart function the usart function is similar to that on the pic16c74b, which includes the brgh = 1 fix. 12.3.1 usart 9-bit receiver with address detect when the rx9 bit is set in the rcsta register, 9-bits are received and the ninth bit is placed in the rx9d bit of the rcsta register. the usart module has a spe- cial provision for multi-processor communication. mul- tiprocessor communication is enabled by setting the aden bit (rcsta<3>) along with the rx9 bit. the port is now programmed such that when the last bit is received, the contents of the receive shift register (rsr) are transferred to the receive buffer, the ninth bit of the rsr (rsr<8>) is transferred to rx9d, and the receive interrupt is set if and only if rsr<8> = 1. this feature can be used in a multi-processor system as fol- lows: a master processor intends to transmit a block of data to one of many slaves. it must first send out an address byte that identifies the target slave. an address byte is identified by setting the ninth bit (rsr<8>) to a '1' (instead of a '0' for a data byte). if the aden and rx9 bits are s et in the slaves rcsta register, enabling mul- tiprocessor communication, all data bytes will be ignored. however, if the ninth received bit is equal to a 1, indicating that the received byte is an address, the slave will be interrupted and the contents of the rsr register will be transferred into the receive buffer. this allows the slave to be interrupted only by addresses, so that the slave can examine the received byte to see if it is being addressed. the addressed slave will then clear its aden bit and prepare to receive data bytes from the master. when aden is enabled (='1'), all data bytes are ignored. following the stop bit, the data will not be loaded into the receive buffer, and no interrupt will occur. if another byte is shifted into the rsr register, the previous data byte will be lost. the aden bit will only take effect when the receiver is configured in 9-bit mode (rx9 = '1'). when aden is disabled (='0'), all data bytes are received and the 9th bit can be used as the parity bit. the receive block diagram is shown in figure 12-8. reception is enabled by setting bit cren (rcsta<4>). 12.3.1.1 setting up 9-bit mode with address detect steps to follow when setting up an asynchronous or synchronous reception with address detect enabled: 1. initialize the spbrg register for the appropriate baud rate. if a high speed baud rate is desired, set bit brgh. 2. enable asynchronous or synchronous commu- nication by setting or clearing bit sync and set- ting bit spen. 3. if interrupts are desired, then set enable bit rcie. 4. set bit rx9 to enable 9-bit reception. 5. set aden to enable address detect. 6. enable the reception by setting enable bit cren or sren. 7. flag bit rcif will be set when reception is com- plete, and an interrupt will be generated if enable bit rcie was set. 8. read the 8-bit received data by reading the rcreg register to determine if the device is being addressed. 9. if any error occurred, clear the error by clearing enable bit cren if it was already set. 10. if the device has been addressed (rsr<8> = 1 with address match enabled), clear the aden and rcif bits to allow data bytes and address bytes to be read into the receive buffer and inter- rupt the cpu.
pic16f62x ds40300b-page 84 preliminary 1999 microchip technology inc. table 12-1: registers associated with asynchronous reception addr name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por value on all other resets 0ch pir1 eeif cmif rcif txif ccp1if tmr2if tmr1if 0000 -000 0000 -000 18h rcsta spen rx9 sren cren aden ferr oerr rx9d 0000 -00x 0000 -00x 1ah rcreg rx7 rx6 rx5 rx4 rx3 rx2 rx1 rx0 0000 0000 0000 0000 8ch pie1 eeie cmie rcie txie ccp1ie tmr2ie tmr1ie 0000 -000 0000 -000 98h txsta csrc tx9 txen sync brgh trmt tx9d 0000 -010 0000 -010 99h spbrg baud rate generator register 0000 0000 0000 0000 legend: x = unknown, - = unimplemented locations read as '0'. shaded cells are not used for asynchronous reception. 12.4 usart synchronous master mode in synchronous master mode, the data is transmitted in a half-duplex manner, i.e. transmission and reception do not occur at the same time. when transmitting data, the reception is inhibited and vice versa. synchronous mode is entered by setting bit sync (txsta<4>). in addition enable bit spen (rcsta<7>) is set in order to configure the rb2/tx/ck and rb1/rx/dt i/o pins to ck (clock) and dt (data) lines respectively. the master mode indicates that the processor transmits the master clock on the ck line. the master mode is entered by setting bit csrc (txsta<7>). 12.4.1 usart synchronous master transmission the usart transmitter block diagram is shown in figure 12-5. the heart of the transmitter is the transmit (serial) shift register (tsr). the shift register obtains its data from the read/write transmit buffer register txreg. the txreg register is loaded with data in software. the tsr register is not loaded until the last bit has been transmitted from the previous load. as soon as the last bit is transmitted, the tsr is loaded with new data from the txreg (if available). once the txreg register transfers the data to the tsr register (occurs in one tcycle), the txreg is empty and inter- rupt bit, txif (pir1<4>) is set. the interrupt can be enabled/disabled by setting/clearing enable bit txie (pie1<4>). flag bit txif will be set regardless of the state of enable bit txie and cannot be cleared in soft- ware. it will reset only when new data is loaded into the txreg register. while flag bit txif indicates the status of the txreg register, another bit trmt (txsta<1>) shows the status of the tsr register. trmt is a read only bit which is set when the tsr is empty. no inter- rupt logic is tied to this bit, so the user has to poll this bit in order to determine if the tsr register is empty. the tsr is not mapped in data memory so it is not available to the user. transmission is enabled by setting enable bit txen (txsta<5>). the actual transmission will not occur until the txreg register has been loaded with data. the first data bit will be shifted out on the next available rising edge of the clock on the ck line. data out is sta- ble around the falling edge of the synchronous clock (figure 12-12). the transmission can also be started by first loading the txreg register and then setting bit txen (figure 12-13). this is advantageous when slow baud rates are selected, since the brg is kept in reset when bits txen, cren, and sren are clear. setting enable bit txen will start the brg, creating a shift clock immediately. normally when transmission is first started, the tsr register is empty, so a transfer to the txreg register will result in an immediate transfer to tsr resulting in an empty txreg. back-to-back trans- fers are possible. clearing enable bit txen, during a transmission, will cause the transmission to be aborted and will reset the transmitter. the dt and ck pins will revert to hi-imped- ance. if either bit cren or bit sren is set, during a transmission, the transmission is aborted and the dt pin reverts to a hi-impedance state (for a reception). the ck pin will remain an output if bit csrc is set (internal clock). the transmitter logic however is not reset although it is disconnected from the pins. in order to reset the transmitter, the user has to clear bit txen. if bit sren is set (to interrupt an on-going transmission and receive a single word), then after the single word is received, bit sren will be cleared and the serial port will revert back to transmitting since bit txen is still set. the dt line will immediately switch from hi-impedance receive mode to transmit and start driving. to avoid this, bit txen should be cleared. in order to select 9-bit transmission, the tx9 (txsta<6>) bit should be set and the ninth bit should be written to bit tx9d (txsta<0>). the ninth bit must be written before writing the 8-bit data to the txreg register. this is because a data write to the txreg can result in an immediate transfer of the data to the tsr register (if the tsr is empty). if the tsr was empty and the txreg was written before writing the new tx9d, the present value of bit tx9d is loaded.
1999 microchip technology inc. preliminary ds40300b-page 85 pic16f62x steps to follow when setting up a synchronous master transmission: 1. initialize the spbrg register for the appropriate baud rate (section 12.1). 2. enable the synchronous master serial port by setting bits sync, spen, and csrc. 3. if interrupts are desired, then set enable bit txie. 4. if 9-bit transmission is desired, then set bit tx9. 5. enable the transmission by setting bit txen. 6. if 9-bit transmission is selected, the ninth bit should be loaded in bit tx9d. 7. start transmission by loading data to the txreg register. table 12-2: registers associated with synchronous master transmission figure 12-12: synchronous transmission figure 12-13: synchronous transmission (through txen) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por value on all other resets 0ch pir1 eeif cmif rcif txif ccp1if tmr2if tmr1if 0000 -000 0000 -000 18h rcsta spen rx9 sren cren aden ferr oerr rx9d 0000 -00x 0000 -00x 19h txreg usart transmit register 0000 0000 0000 0000 8ch pie1 eeie cmie rcie txie ccp1ie tmr2ie tmr1ie 0000 -000 0000 -000 98h txsta csrc tx9 txen sync brgh trmt tx9d 0000 -010 0000 -010 99h spbrg baud rate generator register 0000 0000 0000 0000 legend: x = unknown, - = unimplemented, read as '0'. shaded cells are not used for synchronous master transmission. bit 0 bit 1 bit 7 word 1 q1q2 q3q4 q1 q2q3 q4 q1 q2q3 q4 q1 q2q3 q4 q1 q2 q3q4 q3q4 q1q2 q3q4 q1q2 q3q4 q1q2 q3 q4 q1 q2q3 q4 q1 q2q3 q4 q1 q2q3 q4 bit 2 bit 0 bit 1 bit 7 rb1/rx/dt pin rb2/tx/ck pin write to txreg reg txif bit (interrupt flag) trmt txen bit '1' '1' note: sync master mode; spbrg = '0'. continuous transmission of two 8-bit words word 2 trmt bit write word1 write word2 rb1/rx/dt pin rb2/tx/ck pin write to txreg reg txif bit trmt bit bit0 bit1 bit2 bit6 bit7 txen bit
pic16f62x ds40300b-page 86 preliminary 1999 microchip technology inc. 12.4.2 usart synchronous master reception once synchronous mode is selected, reception is enabled by setting either enable bit sren (rcsta<5>) or enable bit cren (rcsta<4>). data is sampled on the rb1/rx/dt pin on the falling edge of the clock. if enable bit sren is set, then only a single word is received. if enable bit cren is set, the reception is continuous until cren is cleared. if both bits are set then cren takes precedence. after clocking the last bit, the received data in the receive shift register (rsr) is transferred to the rcreg register (if it is empty). when the transfer is complete, interrupt flag bit rcif (pir1<5>) is set. the actual interrupt can be enabled/disabled by setting/clearing enable bit rcie (pie1<5>). flag bit rcif is a read only bit which is reset by the hardware. in this case it is reset when the rcreg register has been read and is empty. the rcreg is a double buffered register, i.e. it is a two deep fifo. it is possible for two bytes of data to be received and transferred to the rcreg fifo and a third byte to begin shifting into the rsr register. on the clocking of the last bit of the third byte, if the rcreg register is still full then overrun error bit oerr (rcsta<1>) is set. the word in the rsr will be lost. the rcreg register can be read twice to retrieve the two bytes in the fifo. bit oerr has to be cleared in software (by clearing bit cren). if bit oerr is set, transfers from the rsr to the rcreg are inhibited, so it is essential to clear bit oerr if it is set. the 9th receive bit is buffered the same way as the receive data. reading the rcreg register, will load bit rx9d with a new value, therefore it is essential for the user to read the rcsta register before reading rcreg in order not to lose the old rx9d information. steps to follow when setting up a synchronous master reception: 1. initialize the spbrg register for the appropriate baud rate. (section 12.1) 2. enable the synchronous master serial port by setting bits sync, spen, and csrc. 3. ensure bits cren and sren are clear. 4. if interrupts are desired, then set enable bit rcie. 5. if 9-bit reception is desired, then set bit rx9. 6. if a single reception is required, set bit sren. for continuous reception set bit cren. 7. interrupt flag bit rcif will be set when reception is complete and an interrupt will be generated if enable bit rcie was set. 8. read the rcsta register to get the ninth bit (if enabled) and determine if any error occurred during reception. 9. read the 8-bit received data by reading the rcreg register. 10. if any error occurred, clear the error by clearing bit cren. table 12-3: registers associated with synchronous master reception address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on: por value on all other resets 0ch pir1 eeif cmif rcif txif ccp1if tmr2if tmr1if 0000 -000 0000 -000 18h rcsta spen rx9 sren cren aden ferr oerr rx9d 0000 -00x 0000 -00x 1ah rcreg usart receive register 0000 0000 0000 0000 8ch pie1 eepie cmie rcie txie ccp1ie tmr2ie tmr1ie -000 0000 -000 -000 98h txsta csrc tx9 txen sync brgh trmt tx9d 0000 -010 0000 -010 99h spbrg baud rate generator register 0000 0000 0000 0000 legend: x = unknown, - = unimplemented read as '0'. shaded cells are not used for synchronous master reception.
1999 microchip technology inc. preliminary ds40300b-page 87 pic16f62x figure 12-14: synchronous reception (master mode, sren) cren bit rb1/rx/dt pin rb2/tx/ck pin write to bit sren sren bit rcif bit (interrupt) read rxreg note: timing diagram demonstrates sync master mode with bit sren = '1' and bit brg = '0'. q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q2 q1 q2 q3 q4q1 q2 q3 q4 q1 q2 q3 q4q1 q2 q3 q4 q1 q2 q3 q4q1 q2 q3 q4 q1 q2 q3 q4 '0' bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 '0' q1 q2 q3 q4
pic16f62x ds40300b-page 88 preliminary 1999 microchip technology inc. 12.5 usart synchronous slave mode synchronous slave mode differs from the master mode in the fact that the shift clock is supplied externally at the rb2/tx/ck pin (instead of being supplied internally in master mode). this allows the device to transfer or receive data while in sleep mode. slave mode is entered by clearing bit csrc (txsta<7>). 12.5.1 usart synchronous slave transmit the operation of the synchronous master and slave modes are identical except in the case of the sleep mode. if two words are written to the txreg and then the sleep instruction is executed, the following will occur: a) the first word will immediately transfer to the tsr register and transmit. b) the second word will remain in txreg register. c) flag bit txif will not be set. d) when the first word has been shifted out of tsr, the txreg register will transfer the second word to the tsr and flag bit txif will now be set. e) if enable bit txie is set, the interrupt will wake the chip from sleep and if the global interrupt is enabled, the program will branch to the inter- rupt vector (0004h). steps to follow when setting up a synchronous slave transmission: 1. enable the synchronous slave serial port by set- ting bits sync and spen and clearing bit csrc. 2. clear bits cren and sren. 3. if interrupts are desired, then set enable bit txie. 4. if 9-bit transmission is desired, then set bit tx9. 5. enable the transmission by setting enable bit txen. 6. if 9-bit transmission is selected, the ninth bit should be loaded in bit tx9d. 7. start transmission by loading data to the txreg register. 12.5.2 usart synchronous slave reception the operation of the synchronous master and slave modes is identical except in the case of the sleep mode. also, bit sren is a don't care in slave mode. if receive is enabled, by setting bit cren, prior to the sleep instruction, then a word may be received during sleep. on completely receiving the word, the rsr register will transfer the data to the rcreg register and if enable bit rcie bit is set, the interrupt generated will wake the chip from sleep. if the global interrupt is enabled, the program will branch to the interrupt vector (0004h). steps to follow when setting up a synchronous slave reception: 1. enable the synchronous master serial port by setting bits sync and spen and clearing bit csrc. 2. if interrupts are desired, then set enable bit rcie. 3. if 9-bit reception is desired, then set bit rx9. 4. to enable reception, set enable bit cren. 5. flag bit rcif will be set when reception is com- plete and an interrupt will be generated, if enable bit rcie was set. 6. read the rcsta register to get the ninth bit (if enabled) and determine if any error occurred during reception. 7. read the 8-bit received data by reading the rcreg register. 8. if any error occurred, clear the error by clearing bit cren.
1999 microchip technology inc. preliminary ds40300b-page 89 pic16f62x table 12-4: registers associated with synchronous slave transmission table 12-5: registers associated with synchronous slave reception address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por value on all other resets 0ch pir1 eeif cmif rcif txif ccp1if tmr2if tmr1if 0000 -000 0000 -000 18h rcsta spen rx9 sren cren aden ferr oerr rx9d 0000 -00x 0000 -00x 19h txreg usart transmit register 0000 0000 0000 0000 8ch pie1 eeie cmie rcie txie ccp1ie tmr2ie tmr1ie 0000 -000 0000 -000 98h txsta csrc tx9 txen sync brgh trmt tx9d 0000 -010 0000 -010 99h spbrg baud rate generator register 0000 0000 0000 0000 legend: x = unknown, - = unimplemented read as '0'. shaded cells are not used for synchronous slave transmission. address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por value on all other resets 0ch pir1 eeif cmif rcif txif ccp1if tmr2if tmr1if 0000 -000 0000 -000 18h rcsta spen rx9 sren cren aden ferr oerr rx9d 0000 -00x 0000 -00x 1ah rcreg usart receive register 0000 0000 0000 0000 8ch pie1 eeie cmie rcie txie ccp1ie tmr2ie tmr1ie 0000 -000 0000 -000 98h txsta csrc tx9 txen sync brgh trmt tx9d 0000 -010 0000 -010 99h spbrg baud rate generator register 0000 0000 0000 0000 legend: x = unknown, - = unimplemented read as '0'. shaded cells are not used for synchronous slave reception.
pic16f62x ds40300b-page 90 preliminary 1999 microchip technology inc. notes:
pic16f62x ? 1999 microchip technology inc. preliminary ds40300b-page 91 13.0 data eeprom memory the eeprom data memory is readable and writable during normal operation (full v dd range). this memory is not directly mapped in the register file space. instead it is indirectly addressed through the special function registers. there are four sfrs used to read and write this memory. these registers are: ? eecon1 ? eecon2 (not a physically implemented register) ? eedata ? eeadr eedata holds the 8-bit data for read/write, and eeadr holds the address of the eeprom location being accessed. pic16f62x devices have 128 bytes of data eeprom with an address range from 0h to 7fh. the eeprom data memory allows byte read and write. a byte write automatically erases the location and writes the new data (erase before write). the eeprom data memory is rated for high erase/write cycles. the write time is controlled by an on-chip timer. the write- time will vary with voltage and temperature as well as from chip to chip. please refer to ac specifications for exact limits. when the device is code protected, the cpu may continue to read and write the data eeprom memory. the device programmer can no longer access this memory. additional information on the data eeprom is avail- able in the picmicro? mid-range reference manual, (ds33023). register 13-1: eeadr register (address 9bh) 13.1 eeadr the eeadr register can address up to a maximum of 256 bytes of data eeprom. only the first 128 bytes of data eeprom are implemented and only seven of the eight bits in the register (eeadr<6:0>) are required. the upper bit is address decoded. this means that this bit should always be '0' to ensure that the address is in the 128 byte memory space. u r/w r/w r/w r/w r/w r/w r/w eadr6 eadr5 eadr4 eadr3 eadr2 eadr1 eadr0 r = readable bit w = writable bit s = settable bit u = unimplemented bit, read as 0 -n = value at por reset bit7 bit0 bit 7 unimplemented address: must be set to '0' bit 6:0 eeadr : specifies one of 128 locations for eeprom read/write operation
pic16f62x ds40300b-page 92 preliminary ? 1999 microchip technology inc. 13.2 eecon1 and eecon2 registers eecon1 is the control register with five low order bits physically implemented. the upper-three bits are non- existent and read as '0's. control bits rd and wr initiate read and write, respectively. these bits cannot be cleared, only set, in software. they are cleared in hardware at completion of the read or write operation. the inability to clear the wr bit in software prevents the accidental, premature termination of a write operation. the wren bit, when set, will allow a write operation. on power-up, the wren bit is clear. the wrerr bit is set when a write operation is interrupted by a mclr reset or a wdt time-out reset during normal opera- tion. in these situations, following reset, the user can check the wrerr bit and rewrite the location. the data and address will be unchanged in the eedata and eeadr registers. interrupt flag bit eeif in the pir1 register is set when write is complete. this bit must be cleared in software. eecon2 is not a physical register. reading eecon2 will read all '0's. the eecon2 register is used exclusively in the data eeprom write sequence. register 13-2: eecon1 register (address 9ch) devices uuuur/w-xr/w-0r/s-0r/s-x wrerr wren wr rd r = readable bit w = writable bit s = settable bit u = unimplemented bit, read as 0 -n = value at por reset bit7 bit0 bit 7:4 unimplemented: read as '0' bit 3 wrerr : eeprom error flag bit 1 = a write operation is prematurely terminated (any mclr reset, any wdt reset during normal operation or bod detect) 0 = the write operation completed bit 2 wren : eeprom write enable bit 1 = allows write cycles 0 = inhibits write to the data eeprom bit 1 wr : write control bit 1 = initiates a write cycle. (the bit is cleared by hardware once write is complete. the wr bit can only be set (not cleared) in software. 0 = write cycle to the data eeprom is complete bit 0 rd : read control bit 1 = initiates an eeprom read (read takes one cycle. rd is cleared in hardware. the rd bit can only be set (not cleared) in software). 0 = does not initiate an eeprom read
pic16f62x ? 1999 microchip technology inc. preliminary ds40300b-page 93 13.3 reading the eeprom data memory to read a data memory location, the user must write the address to the eeadr register and then set con- trol bit rd (eecon1<0>). the data is available, in the very next cycle, in the eedata register; therefore it can be read in the next instruction. eedata will hold this value until another read or until it is written to by the user (during a write operation). example 13-1: data eeprom read bcf status, rp0 ; bank 0 movlw config_addr ; movwf eeadr ; address to read bsf status, rp0 ; bank 1 bsf eecon1, rd ; ee read bcf status, rp0 ; bank 0 movf eedata, w ; w = eedata 13.4 writing to the eeprom data memory to write an eeprom data location, the user must first write the address to the eeadr register and the data to the eedata register. then the user must follow a specific sequence to initiate the write for each byte. example 13-2: data eeprom write bsf status, rp0 ; bank 1 bsf eecon1, wren ; enable write bcf intcon, gie ; disable ints. movlw 55h ; movwf eecon2 ; write 55h movlw aah ; movwf eecon2 ; write aah bsf eecon1,wr ; set wr bit ; begin write bsf intcon, gie ; enable ints . the write will not initiate if the above sequence is not exactly followed (write 55h to eecon2, write aah to eecon2, then set wr bit) for each byte. we strongly recommend that interrupts be disabled during this code segment. a cycle count is executed during the required sequence. any number what is not equal to the required cycles to execute the required sequence will cause the data not to be written into the eeprom. additionally, the wren bit in eecon1 must be set to enable write. this mechanism prevents accidental writes to data eeprom due to errant (unexpected) code execution (i.e., lost programs). the user should keep the wren bit clear at all times, except when updating eeprom. the wren bit is not cleared by hardware after a write sequence has been initiated, clearing the wren bit will not affect this write cycle. the wr bit will be inhibited from being set unless the wren bit is set. at the completion of the write cycle, the wr bit is cleared in hardware and the ee write complete interrupt flag bit (eeif) is set. the user can either enable this interrupt or poll this bit. the eeif bit in the pir1 registers must be cleared by software. 13.5 write verify depending on the application, good programming practice may dictate that the value written to the data eeprom should be verified (example 13-3) to the desired value to be written. this should be used in applications where an eeprom bit will be stressed near the specification limit. example 13-3: write verify bcf status, rp0 ; bank 0 : ; any code can go here : ; movf eedata, w ; must be in bank 0 bsf status, rp0 ; bank 1 read bsf eecon1, rd ; yes, read the ; value written bcf status, rp0 ; bank 0 ; ; is the value written (in w reg) and ; read (in eedata) the same? ; subwf eedata, w ; btfss status, z ; is difference 0? goto write_err ; no, write error : ; yes, good write : ; continue program 13.6 protection against spurious write there are conditions when the device may not want to write to the data eeprom memory. to protect against spurious eeprom writes, various mechanisms have been built in. on power-up, wren is cleared. also, the power-up timer (72 ms duration) prevents eeprom write. the write initiate sequence and the wren bit together help prevent an accidental write during brown-out, power glitch, or software malfunction. 13.7 data eeprom operation during code protect when the device is code protected, the cpu is able to read and write unscrambled data to the data eeprom. required se q uence
pic16f62x ds40300b-page 94 preliminary ? 1999 microchip technology inc. table 13-1 registers/bits associated with data eeprom address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on power-on reset value on all other resets 9ah eedata eeprom data register xxxx xxxx uuuu uuuu 9bh eeadr eeprom address register xxxx xxxx uuuu uuuu 9ch eecon1 wrerr wren wr rd ---- x000 ---- q000 9dh eecon2 (1) eeprom control register 2 ---- ---- ---- ---- legend: x = unknown, u = unchanged, - = unimplemented read as '0', q = value depends upon condition. shaded cells are not used by data eeprom. note 1: eecon2 is not a physical register
1999 microchip technology inc. preliminary ds40300b-page 95 pic16f62x 14.0 special features of the cpu special circuits to deal with the needs of real time appli- cations are what sets a microcontroller apart from other processors. the pic16f62x family has a host of such features intended to maximize system reliability, mini- mize cost through elimination of external components, provide power saving operating modes and offer code protection. these are: 1. osc selection 2. reset power-on reset (por) power-up timer (pwrt) oscillator start-up timer (ost) brown-out reset (bod) 3. interrupts 4. watchdog timer (wdt) 5. sleep 6. code protection 7. id locations 8. in-circuit serial programming the pic16f62x has a watchdog timer which is controlled by configuration bits. it runs off its own rc oscillator for added reliability. there are two timers that offer necessary delays on power-up. one is the oscillator start-up timer (ost), intended to keep the chip in reset until the crystal oscillator is stable. the other is the power-up timer (pwrt), which provides a fixed delay of 72 ms (nominal) on power-up only, designed to keep the part in reset while the power supply stabilizes. there is also circuitry to reset the device if a brown-out occurs which provides at least a 72 ms reset. with these three functions on-chip, most applications need no external reset circuitry. the sleep mode is designed to offer a very low current power-down mode. the user can wake-up from sleep through external reset, watchdog timer wake-up or through an interrupt. several oscillator options are also made available to allow the part to fit the application. the er oscillator option saves system cost while the lp crystal option saves power. a set of configuration bits are used to select various options.
pic16f62x ds40300b-page 96 preliminary 1999 microchip technology inc. 14.1 configuration bits the configuration bits can be programmed (read as '0') or left unprogrammed (read as '1') to select various device configurations. these bits are mapped in program memory location 2007h. the user will note that address 2007h is beyond the user program memory space. in fact, it belongs to the special configuration memory space (2000h C 3fffh), which can be accessed only during program- ming. figure 14-1: configuration word cp1 cp0 cp1 cp0 - cpd lvp boden mclre fosc2 pwrte wdte f0sc1 f0sc0 register:config address2007h bit13 bit0 bit 13-10: cp1:cp0: code protection bits (2) code protection for 2k program memory 11 = program memory code protection off 10 = 0400h-07ffh code protected 01 = 0200h-07ffh code protected 00 = 0000h-07ffhcode protected code protection for 1k program memory 11 = program memory code protection off 10 = program memory code protection off 01 = 0200h-03ffh code protected 00 = 0000h-03ffh code protected bit 8: cpd: data code protection bit (3) 1 = data memory code protection off 0 = data memory code protected bit 7: lv p : low voltage programming enable 1 = rb4/pgm pin has pgm function, low voltage programming enabled 0 = rb4/pgm is digital i/o, hv on mclr must be used for programming bit 6: boden : brown-out detect enable bit (1) 1 = bod enabled 0 = bod disabled bit 5: mclre : ra5/mclr pin function select 1 = ra5/mclr pin function is mclr 0 = ra5/mclr pin function is digital i/o, mclr internally tied to v dd bit 3: pwrte : power-up timer enable bit (1) 1 = pwrt disabled 0 = pwrt enabled bit 2: wdte : watchdog timer enable bit 1 = wdt enabled 0 = wdt disabled bit 4,1-0: fosc2:fosc0 : oscillator selection bits (4) 111 = er oscillator: clkout function on ra6/osc2/clkout pin, resistor on ra7/osc1/clkin 110 = er oscillator: i/o function on ra6/osc2/clkout pin, resistor on ra7/osc1/clkin 101 = intrc oscillator: clkout function on ra6/osc2/clkout pin, i/o function on ra7/osc1/clkin 100 = intrc oscillator: i/o function on ra6/osc2/clkout pin, i/o function on ra7/osc1/clkin 011 = ec: i/o function on ra6/osc2/clkout pin, clkin on ra7/osc1/clkin 010 = hs oscillator: high speed crystal/resonator on ra6/osc2/clkout and ra7/osc1/clkin 001 = xt oscillator: crystal/resonator on ra6/osc2/clkout and ra7/osc1/clkin 000 = lp oscillator: low power crystal on ra6/osc2/clkout and ra7/osc1/clkin note 1: enabling brown-out reset automatically enables power-up timer (pwrt) regardless of the value of bit pwrte . ensure the power-up timer is enabled anytime brown-out reset is enabled. 2: all of the cp1:cp0 pairs have to be given the same value to enable the code protection scheme listed. 3: the entire data eeprom will be erased when the code protection is turned off. 4: when mclr is asserted in intrc or er mode, the internal clock oscillator is disabled.
1999 microchip technology inc. preliminary ds40300b-page 97 pic16f62x 14.2 oscillator configurations 14.2.1 oscillator types the pic16f62x can be operated in eight different oscillator options. the user can program three configuration bits (fosc2 thru fosc0) to select one of these eight modes: ? lp low power crystal ? xt crystal/resonator ? hs high speed crystal/resonator ? er external resistor (2 modes) ? intrc internal resistor/capacitor (2 modes) ? ec external clock in 14.2.2 crystal oscillator / ceramic resonators in xt, lp or hs modes a crystal or ceramic resonator is connected to the osc1 and osc2 pins to establish oscillation (figure 14-2). the pic16f62x oscillator design requires the use of a parallel cut crystal. use of a series cut crystal may give a frequency out of the crystal manufacturers specifications. when in xt, lp or hs modes, the device can have an external clock source to drive the osc1 pin (figure 14-3). figure 14-2: crystal operation (or ceramic resonator) (hs, xt or lp osc configuration) figure 14-3: external clock input operation (hs, xt or lp osc configuration) see table 14-1 and table 14-2 for recommended values of c1 and c2. note: a series resistor may be required for at strip cut crystals. c1 c2 xtal osc2 rs osc1 rf sleep to internal logic pic16f62x see note clock from ext. system pic16f62x osc1 osc2 open table 14-1: capacitor selection for ceramic resonators table 14-2: capacitor selection for crystal oscillator ranges characterized: mode freq osc1(c1) osc2(c2) xt 455 khz 2.0 mhz 4.0 mhz 22 - 100 pf 15 - 68 pf 15 - 68 pf 22 - 100 pf 15 - 68 pf 15 - 68 pf hs 8.0 mhz 16.0 mhz 10 - 68 pf 10 - 22 pf 10 - 68 pf 10 - 22 pf higher capacitance increases the stability of the oscillator but also increases the start-up time. these values are for design guidance only. since each resonator has its own characteristics, the user should consult the resonator man- ufacturer for appropriate values of external components. mode freq osc1(c1) osc2(c2) lp 32 khz 200 khz 68 - 100 pf 15 - 30 pf 68 - 100 pf 15 - 30 pf xt 100 khz 2 mhz 4 mhz 68 - 150 pf 15 - 30 pf 15 - 30 pf 150 - 200 pf 15 - 30 pf 15 - 30 pf hs 8 mhz 10 mhz 20 mhz 15 - 30 pf 15 - 30 pf 15 - 30 pf 15 - 30 pf 15 - 30 pf 15 - 30 pf higher capacitance increases the stability of the oscillator but also increases the start-up time. these values are for design guidance only. rs may be required in hs mode as well as xt mode to avoid overdriving crystals with low drive level specification. since each crystal has its own characteristics, the user should consult the crystal manu- facturer for appropriate values of external components.
pic16f62x ds40300b-page 98 preliminary 1999 microchip technology inc. 14.2.3 external crystal oscillator circuit either a prepackaged oscillator can be used or a simple oscillator circuit with ttl gates can be built. prepackaged oscillators provide a wide operating range and better stability. a well-designed crystal oscillator will provide good performance with ttl gates. two types of crystal oscillator circuits can be used; one with series resonance, or one with parallel resonance. figure 14-4 shows implementation of a parallel reso- nant oscillator circuit. the circuit is designed to use the fundamental frequency of the crystal. the 74as04 inverter performs the 180 phase shift that a parallel oscillator requires. the 4.7 k w resistor provides the negative feedback for stability. the 10 k w potentiometers bias the 74as04 in the linear region. this could be used for external oscillator designs. figure 14-4: external parallel resonant crystal oscillator circuit figure 14-5 shows a series resonant oscillator circuit. this circuit is also designed to use the fundamental frequency of the crystal. the inverter performs a 180 phase shift in a series resonant oscillator circuit. the 330 k w resistors provide the negative feedback to bias the inverters in their linear region. figure 14-5: external series resonant crystal oscillator circuit 20 pf +5v 20 pf 10k 4.7k 10k 74as04 xtal 10k 74as04 pic16f62x clkin to other devices 330 k w 74as04 74as04 pic16f62x clkin to o t h e r devices xtal 330 k w 74as04 0.1 m f 14.2.4 external clock in for applications where a clock is already available else- where, users may directly drive the pic16f62x pro- vided that this external clock source meets the ac/dc timing requirements listed in section 17.4. figure 14-6 below shows how an external clock circuit should be configured. figure 14-6: external clock input operation (hs, xt or lp osc configuration) 14.2.5 er oscillator for timing insensitive applications, the er (external resistor) clock mode offers additional cost savings. only one external component, a resistor to v ss , is needed to set the operating frequency of the internal oscillator. the resistor draws a dc bias current which controls the oscillation frequency. in addition to the resistance value, the oscillator frequency will vary from unit to unit, and as a function of supply voltage and tem- perature. since the controlling parameter is a dc cur- rent and not a capacitance, the particular package type and lead frame will not have a significant effect on the resultant frequency. figure 14-7 shows how the controlling resistor is con- nected to the pic16f62x. for rext values below 38k, the oscillator operation may become unstable, or stop completely. for very high rext values (e.g. 1m), the oscillator becomes sensitive to noise, humidity and leakage. thus, we recommend keeping rext between 38k and 1m. figure 14-7: external resistor the electrical specification section shows the relation- ship between the resistance value and the operating frequency as well as frequency variations due to oper- ating temperature for given r and v dd values. the er oscillator mode has two options that control the unused osc2 pin. the first allows it to be used as a general purpose i/o port. the other configures the pin as an output providing the fosc signal (internal clock divided by 4) for test or external synchronization pur- poses. clock from ext. system pic16f62x osc1/ra7 osc2/ra6 ra6 ra7/osc1/clkin ra6/osc2/clkout
1999 microchip technology inc. preliminary ds40300b-page 99 pic16f62x 14.2.6 internal 4 mh z oscillator the internal rc oscillator provides a fixed 4 mhz (nom- inal) system clock at vdd = 5v and 25 c, see electrical specifications section for information on variation over voltage and temperature. 14.2.7 clkout the pic16f62x can be configured to provide a clock out signal by programming the configuration word. the oscillator frequency, divided by 4 can be used for test purposes or to synchronize other logic. 14.3 special feature: d ual speed oscillator modes a software programmable dual speed oscillator mode is provided when the pic16f62x is configured in either er or intrc oscillator modes. this feature allows users to dynamically toggle the oscillator speed between 4mhz and 37khz. in er mode, the 4mhz set- ting will vary depending on the size of the external resistor. also in er mode, the 37khz operation is fixed and does not vary with resistor size. applications that require low current power savings, but cannot tolerate putting the part into sleep, may use this mode. the oscf bit in the pcon register is used to control dual speed mode. see section 4.2.2.6, figure 4-9. 14.4 reset the pic16f62x differentiates between various kinds of reset: a) power-on reset (por) b) mclr reset during normal operation c) mclr reset during sleep d) wdt reset (normal operation) e) wdt wake-up (sleep) f) brown-out detect (bod) some registers are not affected in any reset condition; their status is unknown on por and unchanged in any other reset. most other registers are reset to a reset state on power-on reset, mclr reset, wdt reset and mclr reset during sleep. they are not affected by a wdt wake-up, since this is viewed as the resumption of normal operation. to and pd bits are set or cleared differently in different reset situations as indicated in table 14-4. these bits are used in software to deter- mine the nature of the reset. see table 14-7 for a full description of reset states of all registers. a simplified block diagram of the on-chip reset circuit is shown in figure 14-8. the mclr reset path has a noise filter to detect and ignore small pulses. see table 12-6 for pulse width specification.
pic16f62x ds40300b-page 100 preliminary 1999 microchip technology inc. figure 14-8: simplified block diagram of on-chip reset circuit s r q external reset mclr / v dd osc1/ wdt module v dd rise detect ost/pwrt on-chip (1) er osc wdt time-out power-on reset ost pwrt chip_reset 10-bit ripple-counter reset enable ost enable pwrt sleep see table 14-3 for time-out situations. note 1: this is a separate oscillator from the intrc/ec oscillator. brown-out detect boden clkin pin v pp pin 10-bit ripple-counter q
1999 microchip technology inc. preliminary ds40300b-page 101 pic16f62x 14.5 power-on reset (por), power-up timer (pwrt), oscillator start-up timer (ost) and brown-out detect (bod) 14.5.1 power-on reset (por) the on-chip por circuit holds the chip in reset until v dd has reached a high enough level for proper opera- tion. to take advantage of the por, just tie the mclr pin through a resistor to v dd . this will eliminate exter- nal rc components usually needed to create power-on reset. a maximum rise time for v dd is required. see electrical specifications for details. the por circuit does not produce an internal reset when v dd declines. when the device starts normal operation (exits the reset condition), device operating parameters (voltage, frequency, temperature, etc.) must be met to ensure operation. if these conditions are not met, the device must be held in reset until the operating conditions are met. for additional information, refer to application note an607 power-up trouble shooting. 14.5.2 power-up timer (pwrt) the power-up timer provides a fixed 72 ms (nominal) time-out on power-up only, from por or brown-out reset. the power-up timer operates on an internal rc oscillator. the chip is kept in reset as long as pwrt is active. the pwrt delay allows the v dd to rise to an acceptable level. a configuration bit, pw r te can disable (if set) or enable (if cleared or programmed) the power-up timer. the power-up timer should always be enabled when brown-out reset is enabled. the power-up time delay will vary from chip to chip and due to v dd , temperature and process variation. see dc parameters for details. 14.5.3 oscillator start-up timer (ost) the oscillator start-up timer (ost) provides a 1024 oscillator cycle (from osc1 input) delay after the pwrt delay is over. this ensures that the crystal oscillator or resonator has started and stabilized. the ost time-out is invoked only for xt, lp and hs modes and only on power-on reset or wake-up from sleep. 14.5.4 brown-out detect (bod) the pic16f62x members have on-chip brown-out detect circuitry. a configuration bit, boden, can dis- able (if clear/programmed) or enable (if set) the brown-out detect circuitry. if v dd falls below 4.0v, refer to v bod parameter d005(v bod ) for greater than parameter (tbod) in table 17.1, the brown-out situa- tion will reset the chip. a reset is not guaranteed to occur if v dd falls below 4.0v for less than parameter (tbod). on any reset (power-on, brown-out, watchdog, etc.) the chip will remain in reset until v dd rises above bv dd . the power-up timer will now be invoked and will keep the chip in reset an additional 72 ms. if v dd drops below bv dd while the power-up timer is running, the chip will go back into a brown-out reset and the power-up timer will be re-initialized. once v dd rises above bv dd , the power-up timer will execute a 72 ms reset. the power-up timer should always be enabled when brown-out detect is enabled. figure 14-9 shows typical brown-out situations. figure 14-9: brown-out situations 72 ms bv dd v dd internal reset bv dd v dd internal reset 72 ms <72 ms 72 ms bv dd v dd internal reset
pic16f62x ds40300b-page 102 preliminary 1999 microchip technology inc. 14.5.5 time-out sequence on power-up the time-out sequence is as follows: first pwrt time-out is invoked after por has expired. then ost is activated. the total time-out will vary based on oscillator configuration and p w rte bit status. for example, in er mode with pwrte bit erased (pwrt disabled), there will be no time-out at all. figure 14-10, figure 14-11 and figure 14-12 depict time-out sequences. since the time-outs occur from the por pulse, if mclr is kept low long enough, the time-outs will expire. then bringing mclr high will begin execution immediately (see figure 14-11). this is useful for testing purposes or to synchronize more than one pic16f62x device operating in parallel. table 14-6 shows the reset conditions for some special registers, while table 14-7 shows the reset conditions for all the registers. 14.5.6 power control (pcon)/ status register the power control/status register, pcon (address 8eh) has two bits. bit0 is bod (brown-out). bod is unknown on power-on-reset. it must then be set by the user and checked on subsequent resets to see if bod = 0 indicating that a brown-out has occurred. the bod status bit is a dont care and is not necessarily predictable if the brown-out circuit is disabled (by setting boden bit = 0 in the configuration word). bit1 is por (power-on-reset). it is a 0 on power-on-reset and unaffected otherwise. the user must write a 1 to this bit following a power-on-reset. on a subsequent reset if por is 0, it will indicate that a power-on-reset must have occurred (v dd may have gone too low). table 14-3: time-out in various situations table 14-4: status/pcon bits and their significance legend: u = unchanged, x = unknown oscillator configuration power-up brown-out reset wake-up from sleep pwrte = 0 pwrte = 1 xt, hs, lp 72 ms + 1024 t osc 1024 t osc 72 ms + 1024 t osc 1024 t osc er 72 ms 72 ms por bod to pd 0x11 power-on-reset 0x0x illegal, to is set on por 0xx0 illegal, pd is set on por 10xx brown-out detect 110u wdt reset 1100 wdt wake-up 11uu mclr reset during normal operation 1110 mclr reset during sleep table 14-5: summary of registers associated with brown-out address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por reset value on all other resets (1) 03h status irp rp1 rpo to pd z dc c 0001 1xxx 000q quuu 8eh pcon oscf por bod ---- 1-0x ---- u-uq note 1: other (non power-up) resets include mclr reset, brown-out detect and watchdog timer reset during normal operation.
1999 microchip technology inc. preliminary ds40300b-page 103 pic16f62x table 14-6: initialization condition for special registers condition program counter status register pcon register power-on reset 000h 0001 1xxx ---- 1-0x mclr reset during normal operation 000h 000u uuuu ---- 1-uu mclr reset during sleep 000h 0001 0uuu ---- 1-uu wdt reset 000h 0000 uuuu ---- 1-uu wdt wake-up pc + 1 uuu0 0uuu ---- --uu brown-out detect 000h 000x xuuu ---- 1-u0 interrupt wake-up from sleep pc + 1 (1) uuu1 0uuu ---- --uu legend: u = unchanged, x = unknown, - = unimplemented bit, reads as 0. note 1: when the wake-up is due to an interrupt and global enable bit, gie is set, the pc is loaded with the interrupt vector (0004h) after execution of pc+1.
pic16f62x ds40300b-page 104 preliminary 1999 microchip technology inc. table 14-7: initialization condition for registers register address power-on reset ?mclr reset during normal operation ?mclr reset during sleep ? wdt reset ? brown-out detect (1) ? wake up from sleep through interrupt ? wake up from sleep through wdt time-out w- xxxx xxxx uuuu uuuu uuuu uuuu indf 00h --- tmr0 01h xxxx xxxx uuuu uuuu uuuu uuuu pcl 02h 0000 0000 0000 0000 pc + 1 (3) status 03h 0001 1xxx 000q quuu (4) uuuq quuu (4) fsr 04h xxxx xxxx uuuu uuuu uuuu uuuu porta 05h xxxx 0000 xxxx u000 xxxx 0000 portb 06h xxxx xxxx uuuu uuuu uuuu uuuu t1con 10h --00 0000 --uu uuuu t2con 12h -000 0000 -000 0000 ccp1con 17h --00 0000 --00 0000 rcsta 18h 0000 -00x 0000 -00x cmcon 1fh 0000 0000 0000 0000 uu-- uuuu pclath 0ah ---0 0000 ---0 0000 ---u uuuu intcon 0bh 0000 000x 0000 000u uuuu uqqq (2) pir1 0ch 0000 -000 0000 -000 -q-- ---- (2,5) option 81h 1111 1111 1111 1111 uuuu uuuu trisa 85h 11-1 1111 11-- 1111 uu-u uuuu trisb 86h 1111 1111 1111 1111 uuuu uuuu pie1 8ch 0000 -000 0000 -000 uuuu -uuu pcon 8eh ---- 1-0x ---- 1-uq (1,6) ---- --uu txsta 98h 0000 -010 0000 -010 eecon1 9ch ---- x000 ---- q000 vrcon 9fh 000- 0000 000- 0000 uuu- uuuu legend: u = unchanged, x = unknown, - = unimplemented bit, reads as 0, q = value depends on condition. note 1: if v dd goes too low, power-on reset will be activated and registers will be affected differently. 2: one or more bits in intcon, pir1 and/or pir2 will be affected (to cause wake-up). 3: when the wake-up is due to an interrupt and the gie bit is set, the pc is loaded with the interrupt vector (0004h). 4: see table 14-6 for reset value for specific condition. 5: if wake-up was due to comparator input changing, then bit 6 = 1. all other interrupts generating a wake-up will cause bit 6 = u. 6: if reset was due to brown-out, then bit 0 = 0. all other resets will cause bit 0 = u.
1999 microchip technology inc. preliminary ds40300b-page 105 pic16f62x figure 14-10: time-out sequence on power-up (mclr not tied to v dd ): case 1 figure 14-11: time-out sequence on power-up (mclr not tied to v dd ): case 2 figure 14-12: time-out sequence on power-up (mclr tied to v dd ) t pwrt t ost v dd mclr internal por pwrt time-out ost time-out internal reset v dd mclr internal por pwrt time-out ost time-out internal reset t pwrt t ost t pwrt t ost v dd mclr internal por pwrt time-out ost time-out internal reset
pic16f62x ds40300b-page 106 preliminary 1999 microchip technology inc. figure 14-13: external power-on reset circuit (for slow v dd power-up) note 1: external power-on reset circuit is required only if v dd power-up slope is too slow. the diode d helps discharge the capacitor quickly when v dd powers down. 2: < 40 k w is recommended to make sure that voltage drop across r does not violate the devices electrical specification. 3: r1 = 100 w to 1 k w will limit any current flowing into mclr from external capacitor c in the event of mclr /v pp pin breakdown due to electrostatic discharge (esd) or electrical overstress (eos). c r1 r d v dd mclr pic16f62x v dd figure 14-14: external brown-out protection circuit 1 figure 14-15: external brown-out protection circuit 2 note 1: this circuit will activate reset when v dd goes below (vz + 0.7v) where vz = zener voltage. 2: internal brown-out reset circuitry should be disabled when using this circuit. v dd 33k 10k 40k v dd mclr pic16f62x note 1: this brown-out circuit is less expensive, albeit less accurate. transistor q1 turns off when v dd is below a certain level such that: 2: internal brown-out reset should be disabled when using this circuit. 3: resistors should be adjusted for the charac- teristics of the transistor. v dd x r1 r1 + r2 = 0.7 v v dd r2 40k v dd mclr pic16f62x r1 q1
1999 microchip technology inc. preliminary ds40300b-page 107 pic16f62x 14.6 interrupts the pic16f62x has 10 sources of interrupt: ? external interrupt rb0/int ? tmr0 overflow interrupt ? portb change interrupts (pins rb7:rb4) ? comparator interrupt ? usart interrupt ? ccp interrupt ? tmr1 overflow interrupt ? tmr2 match interrupt the interrupt control register (intcon) records individual interrupt requests in flag bits. it also has individual and global interrupt enable bits. a global interrupt enable bit, gie (intcon<7>) enables (if set) all un-masked interrupts or disables (if cleared) all interrupts. individual interrupts can be disabled through their corresponding enable bits in intcon register. gie is cleared on reset. the return from interrupt instruction, retfie , exits interrupt routine as well as sets the gie bit, which re-enable rb0/int interrupts. the int pin interrupt, the rb port change interrupt and the tmr0 overflow interrupt flags are contained in the intcon register. the peripheral interrupt flag is contained in the special register pir1. the corresponding interrupt enable bit is contained in special registers pie1. when an interrupt is responded to, the gie is cleared to disable any further interrupt, the return address is pushed into the stack and the pc is loaded with 0004h. once in the interrupt service routine the source(s) of the interrupt can be determined by polling the interrupt flag bits. the interrupt flag bit(s) must be cleared in soft- ware before re-enabling interrupts to avoid rb0/int recursive interrupts. for external interrupt events, such as the int pin or portb change interrupt, the interrupt latency will be three or four instruction cycles. the exact latency depends when the interrupt event occurs (figure 14-17). the latency is the same for one or two cycle instructions. once in the interrupt service routine the source(s) of the interrupt can be determined by poll- ing the interrupt flag bits. the interrupt flag bit(s) must be cleared in software before re-enabling interrupts to avoid multiple interrupt requests. individual interrupt flag bits are set regardless of the status of their corresponding mask bit or the gie bit. note 1: individual interrupt flag bits are set regardless of the status of their corresponding mask bit or the gie bit. 2: when an instruction that clears the gie bit is executed, any interrupts that were pending for execution in the next cycle are ignored. the cpu will execute a nop in the cycle immediately following the instruction which clears the gie bit. the interrupts which were ignored are still pending to be serviced when the gie bit is set again. figure 14-16: interrupt logic tmr2if tmr2ie ccp1if ccp1ie cmif cmie txif txie rcif rcie t0if t0ie intf inte rbif rbie gie peie wake-up (if in sleep mode) interrupt to cpu eeie eeif tmr1if tmr1ie
pic16f62x ds40300b-page 108 preliminary 1999 microchip technology inc. 14.6.1 rb0/int interrupt external interrupt on rb0/int pin is edge triggered: either rising if intedg bit (option<6>) is set, or fall- ing, if intedg bit is clear. when a valid edge appears on the rb0/int pin, the intf bit (intcon<1>) is set. this interrupt can be disabled by clearing the inte control bit (intcon<4>). the intf bit must be cleared in software in the interrupt service routine before re-enabling this interrupt. the rb0/int interrupt can wake-up the processor from sleep, if the inte bit was set prior to going into sleep. the status of the gie bit decides whether or not the processor branches to the interrupt vector following wake-up. see section 14.9 for details on sleep and figure 14-19 for timing of wake-up from sleep through rb0/int interrupt. 14.6.2 tmr0 interrupt an overflow (ffh ? 00h) in the tmr0 register will set the t0if (intcon<2>) bit. the interrupt can be enabled/disabled by setting/clearing t0ie (intcon<5>) bit. for operation of the timer0 module, see section 6.0. 14.6.3 portb interrupt an input change on portb <7:4> sets the rbif (intcon<0>) bit. the interrupt can be enabled/dis- abled by setting/clearing the rbie (intcon<4>) bit. for operation of portb (section 5.2). 14.6.4 comparator interrupt see section 9.6 for complete description of comparator interrupts. note: if a change on the i/o pin should occur when the read operation is being executed (start of the q2 cycle), then the rbif inter- rupt flag may not get set. figure 14-17: int pin interrupt timing table 14-8: summary of interrupt registers address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por reset value on all other resets (1) 0bh intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000u 0ch pir1 eeif cmif rcif txif ccp1if tmr2if tmr1if 0000 -000 0000 -000 8ch pie1 eeie cmie rcie txie ccp1ie tmr2ie tmr1ie 0000 -000 0000 -000 note 1: other (non power-up) resets include mclr reset, brown-out reset and watchdog timer reset during normal operation. q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 osc1 clkout int pin intf flag (intcon<1>) gie bit (intcon<7>) instruction flow pc instruction fetched instruction executed interrupt latency pc pc+1 pc+1 0004h 0005h inst (0004h) inst (0005h) dummy cycle inst (pc) inst (pc+1) inst (pc-1) inst (0004h) dummy cycle inst (pc) 1 4 5 1 2 3 note 1: intf flag is sampled here (every q1). 2: asynchronous interrupt latency = 3-4 tcy. synchronous latency = 3 tcy, where tcy = instruction cycle time. latency is the same whether inst (pc) is a single cycle or a 2-cycle instruction. 3: clkout is available only in er oscillator mode. 4: for minimum width of int pulse, refer to ac specs. 5: intf is enabled to be set anytime during the q4-q1 cycles.
1999 microchip technology inc. preliminary ds40300b-page 109 pic16f62x 14.7 context saving during interrupts during an interrupt, only the return pc value is saved on the stack. typically, users may wish to save key reg- isters during an interrupt e.g. w register and status register. this will have to be implemented in software. example 14-1 stores and restores the status and w registers. the user register, w_temp, must be defined in both banks and must be defined at the same offset from the bank base address (i.e., w_temp is defined at 0x20 in bank 0 and it must also be defined at 0xa0 in bank 1). the user register, status_temp, must be defined in bank 0. the example 14-1: ? stores the w register ? stores the status register in bank 0 ? executes the isr code ? restores the status (and bank select bit register) ? restores the w register example 14-1: saving the status and w registers in ram movwf w_temp ;copy w to temp register, ;could be in either bank swapf status,w ;swap status to be saved into w bcf status,rp0 ;change to bank 0 regardless ;of current bank movwf status_temp ;save status to bank 0 ;register : : (isr) : swapf status_temp,w ;swap status_temp register ;into w, sets bank to original ;state movwf status ;move w into status register swapf w_temp,f ;swap w_temp swapf w_temp,w ;swap w_temp into w 14.8 watchdog timer (wdt) the watchdog timer is a free running on-chip rc oscil- lator which does not require any external components. this rc oscillator is separate from the er oscillator of the clkin pin. that means that the wdt will run, even if the clock on the osc1 and osc2 pins of the device has been stopped, for example, by execution of a sleep instruction. during normal operation, a wdt time-out generates a device reset. if the device is in sleep mode, a wdt time-out causes the device to wake-up and continue with normal operation. the wdt can be permanently disabled by programming the con- figuration bit wdte as clear (section 14.1). 14.8.1 wdt period the wdt has a nominal time-out period of 18 ms, (with no prescaler). the time-out periods vary with tempera- ture, v dd and process variations from part to part (see dc specs). if longer time-out periods are desired, a prescaler with a division ratio of up to 1:128 can be assigned to the wdt under software control by writing to the option register. thus, time-out periods up to 2.3 seconds can be realized. the clrwdt and sleep instructions clear the wdt and the postscaler, if assigned to the wdt, and prevent it from timing out and generating a device reset. the to bit in the status register will be cleared upon a watchdog timer time-out. 14.8.2 wdt programming considerations it should also be taken in account that under worst case conditions (v dd = min., temperature = max., max. wdt prescaler) it may take several seconds before a wdt time-out occurs.
pic16f62x ds40300b-page 110 preliminary 1999 microchip technology inc. figure 14-18: watchdog timer block diagram table 14-9: summary of watchdog timer registers address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por reset value on all other resets 2007h config. bits lvp boren mclre fosc2 pwrte wdte fosc1 fosc0 uuuu uuuu uuuu uuuu 81h option rbpu intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 1111 1111 legend: shaded cells are not used by the watchdog timer. note: _ = unimplemented location, read as 0 + = reserved for future use from tmr0 clock source (figure 6-6) to tmr0 (figure 6-6) postscaler watchdog timer m u x psa 8 - to -1 mux psa wdt time-out 1 0 0 1 wdt enable bit ps<2:0> ? ? note: t0se, t0cs, psa, ps0-ps2 are bits in the option register. 8 mux
1999 microchip technology inc. preliminary ds40300b-page 111 pic16f62x 14.9 power-down mode (sleep) the power-down mode is entered by executing a sleep instruction. if enabled, the watchdog timer will be cleared but keeps running, the pd bit in the status register is cleared, the to bit is set, and the oscillator driver is turned off. the i/o ports maintain the status they had, before sleep was executed (driving high, low, or hi-impedance). for lowest current consumption in this mode, all i/o pins should be either at v dd , or v ss , with no external circuitry drawing current from the i/o pin and the com- parators and v ref should be disabled. i/o pins that are hi-impedance inputs should be pulled high or low exter- nally to avoid switching currents caused by floating inputs. the t0cki input should also be at v dd or v ss for lowest current consumption. the contribution from on chip pull-ups on portb should be considered. the mclr pin must be at a logic high level (v ihmc ). 14.9.1 wake-up from sleep the device can wake-up from sleep through one of the following events: 1. external reset input on mclr pin 2. watchdog timer wake-up (if wdt was enabled) 3. interrupt from rb0/int pin, rb port change, or the peripheral interrupt (comparator). note: it should be noted that a reset generated by a wdt time-out does not drive mclr pin low. the first event will cause a device reset. the two latter events are considered a continuation of program exe- cution. the to and pd bits in the status register can be used to determine the cause of device reset. pd bit, which is set on power-up is cleared when sleep is invoked. to bit is cleared if wdt wake-up occurred. when the sleep instruction is being executed, the next instruction (pc + 1) is pre-fetched. for the device to wake-up through an interrupt event, the correspond- ing interrupt enable bit must be set (enabled). wake-up is regardless of the state of the gie bit. if the gie bit is clear (disabled), the device continues execution at the instruction after the sleep instruction. if the gie bit is set (enabled), the device executes the instruction after the sleep instruction and then branches to the inter- rupt address (0004h). in cases where the execution of the instruction following sleep is not desirable, the user should have an nop after the sleep instruction. the wdt is cleared when the device wakes-up from sleep, regardless of the source of wake-up. note: if the global interrupts are disabled (gie is cleared), but any interrupt source has both its interrupt enable bit and the correspond- ing interrupt flag bits set, the device will immediately wakeup from sleep. the sleep instruction is completely executed. figure 14-19: wake-up from sleep through interrupt q1 q2 q3 q4 q1 q2 q3 q4 q1 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 osc1 clkout(4) int pin intf flag (intcon<1>) gie bit (intcon<7>) instruction flow pc instruction fetched instruction executed pc pc+1 pc+2 inst(pc) = sleep inst(pc - 1) inst(pc + 1) sleep processor in sleep interrupt latency (note 2) inst(pc + 2) inst(pc + 1) inst(0004h) inst(0005h) inst(0004h) dummy cycle pc + 2 0004h 0005h dummy cycle t ost (2) pc+2 note 1: xt, hs or lp oscillator mode assumed. 2: t ost = 1024t osc (drawing not to scale). approximately 1 m s delay will be there for er osc mode. 3: gie = '1' assumed. in this case after wake- up, the processor jumps to the interrupt routine. if gie = '0', execution will cont inue in-line. 4: clkout is not available in these osc modes, but shown here for timing reference.
pic16f62x ds40300b-page 112 preliminary 1999 microchip technology inc. 14.10 code protection if the code protection bit(s) have not been programmed, the on-chip program memory can be read out for verification purposes. 14.11 id locations four memory locations (2000h-2003h) are designated as id locations where the user can store checksum or other code-identification numbers. these locations are not accessible during normal execution but are readable and writable during program/verify. only the least significant 4 bits of the id locations are used. 14.12 in-circuit serial programming the pic16f62x microcontrollers can be serially programmed while in the end application circuit. this is simply done with two lines for clock and data, and three other lines for power, ground, and the programming voltage. this allows customers to manufacture boards with unprogrammed devices, and then program the microcontroller just before shipping the product. this also allows the most recent firmware or a custom firmware to be programmed. the device is placed into a program/verify mode by holding the rb6 and rb7 pins low while raising the mclr (v pp ) pin from v il to v ihh (see programming specification). rb6 becomes the programming clock and rb7 becomes the programming data. both rb6 and rb7 are schmitt trigger inputs in this mode. after reset, to place the device into programming/verify mode, the program counter (pc) is at location 00h. a 6-bit command is then supplied to the device. depending on the command, 14-bits of program data are then supplied to or from the device, depending if the command was a load or a read. for complete details of serial programming, please refer to the programming specifications. a typical in-circuit serial programming connection is shown in figure 14-20. note: the entire data eeprom and flash program memory will be erased when the code protection is turned off. the intrc calibration data is not erased. figure 14-20: typical in-circuit serial programming connection 14.13 low voltage programming the lvp bit of the configuration word, enables the low voltage programming. this mode allows the microcon- troller to be programmed via icsp using only a 5v source. this mode removes the requirement of v ihh to be placed on the mclr pin. the lvp bit is normally erased to '1' which enables the low voltage program- ming. in this mode, the rb4/pgm pin is dedicated to the programming function and ceases to be a general purpose i/o pin. the device will enter programming mode when a '1' is placed on the rb4/pgm pin. the hv programming mode is still available by placing v ihh on the mclr pin. if low-voltage programming mode is not used, the lvp bit can be programmed to a '0' and rb4/pgm becomes a digital i/o pin. to program the device, v ihh must be placed onto mclr during programming. the lvp bit may only be programmed when programming is entered with v ihh on mclr . the lvp bit cannot be programmed when programming is entered with rb4/pgm. it should be noted, that once the lvp bit is programmed to 0, only the high voltage programming mode is avail- able and only high voltage programming mode can be used to program the device. note 1: while in this mode the rb4 pin can no longer be used as a general purpose i/o pin. 2: v dd must be 5.0v + 10% during erase/pro- gram operations while in low voltage pro- gramming mode. external connector signals to normal connections to normal connections pic16f62x v dd v ss ra5/mclr /thv rb6 rb7 +5v 0v v pp clk data i/o v dd
1999 microchip technology inc. preliminary ds40300b-page 113 pic16f62x 15.0 instruction set summary each pic16f62x instruction is a 14-bit word divided into an opcode which specifies the instruction type and one or more operands which further specify the operation of the instruction. the pic16f62x instruc- tion set summary in table 15-2 lists byte-oriented , bit-oriented , and literal and control operations. table 15-1 shows the opcode field descriptions. for byte-oriented instructions, 'f' represents a file register designator and 'd' represents a destination designator. the file register designator specifies which file register is to be used by the instruction. the destination designator specifies where the result of the operation is to be placed. if 'd' is zero, the result is placed in the w register. if 'd' is one, the result is placed in the file register specified in the instruction. for bit-oriented instructions, 'b' represents a bit field designator which selects the number of the bit affected by the operation, while 'f' represents the number of the file in which the bit is located. for literal and control operations, 'k' represents an eight or eleven bit constant or literal value. table 15-1: opcode field descriptions field description f register file address (0x00 to 0x7f) w working register (accumulator) b bit address within an 8-bit file register k literal field, constant data or label x don't care location (= 0 or 1) the assembler will generate code with x = 0. it is the recommended form of use for compatibility with all microchip software tools. d destination select; d = 0: store result in w, d = 1: store result in file register f. default is d = 1 label label name tos top of stack pc program counter pclath program counter high latch gie global interrupt enable bit wdt watchdog timer/counter to time-out bit pd power-down bit dest destination either the w register or the specified register file location [ ] options ( ) contents ? assigned to < > register bit field ? in the set of i talics user defined term (font is courier) the instruction set is highly orthogonal and is grouped into three basic categories: ? byte-oriented operations ? bit-oriented operations ? literal and control operations all instructions are executed within one single instruction cycle, unless a conditional test is true or the program counter is changed as a result of an instruction. in this case, the execution takes two instruction cycles with the second cycle executed as a nop. one instruction cycle consists of four oscillator periods. thus, for an oscillator frequency of 4 mhz, the normal instruction execution time is 1 m s. if a conditional test is true or the program counter is changed as a result of an instruction, the instruction execution time is 2 m s. table 15-1 lists the instructions recognized by the mpasm assembler. figure 15-1 shows the three general formats that the instructions can have. all examples use the following format to represent a hexadecimal number: 0xhh where h signifies a hexadecimal digit. figure 15-1: general format for instructions note: to maintain upward compatibility with future picmicro ? products, do not use the option and tris instructions. byte-oriented file register operations 13 8 7 6 0 d = 0 for destination w opcode d f (file #) d = 1 for destination f f = 7-bit file register address bit-oriented file register operations 13 10 9 7 6 0 opcode b (bit #) f (file #) b = 3-bit bit address f = 7-bit file register address literal and control operations 13 8 7 0 opcode k (literal) k = 8-bit immediate value 13 11 10 0 opcode k (literal) k = 11-bit immediate value general call and goto instructions only
pic16f62x ds40300b-page 114 preliminary 1999 microchip technology inc. table 15-2: pic16f62x instruction set mnemonic, operands description cycles 14-bit opcode status affected notes msb lsb byte-oriented file register operations addwf andwf clrf clrw comf decf decfsz incf incfsz iorwf movf movwf nop rlf rrf subwf swapf xorwf f, d f, d f - f, d f, d f, d f, d f, d f, d f, d f - f, d f, d f, d f, d f, d add w and f and w with f clear f clear w complement f decrement f decrement f, skip if 0 increment f increment f, skip if 0 inclusive or w with f move f move w to f no operation rotate left f through carry rotate right f through carry subtract w from f swap nibbles in f exclusive or w with f 1 1 1 1 1 1 1(2) 1 1(2) 1 1 1 1 1 1 1 1 1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0111 0101 0001 0001 1001 0011 1011 1010 1111 0100 1000 0000 0000 1101 1100 0010 1110 0110 dfff dfff lfff 0000 dfff dfff dfff dfff dfff dfff dfff lfff 0xx0 dfff dfff dfff dfff dfff ffff ffff ffff 0011 ffff ffff ffff ffff ffff ffff ffff ffff 0000 ffff ffff ffff ffff ffff c,dc,z z z z z z z z z c c c,dc,z z 1,2 1,2 2 1,2 1,2 1,2,3 1,2 1,2,3 1,2 1,2 1,2 1,2 1,2 1,2 1,2 bit-oriented file register operations bcf bsf btfsc btfss f, b f, b f, b f, b bit clear f bit set f bit test f, skip if clear bit test f, skip if set 1 1 1 (2) 1 (2) 01 01 01 01 00bb 01bb 10bb 11bb bfff bfff bfff bfff ffff ffff ffff ffff 1,2 1,2 3 3 literal and control operations addlw andlw call clrwdt goto iorlw movlw retfie retlw return sleep sublw xorlw k k k - k k k - k - - k k add literal and w and literal with w call subroutine clear watchdog timer go to address inclusive or literal with w move literal to w return from interrupt return with literal in w return from subroutine go into standby mode subtract w from literal exclusive or literal with w 1 1 2 1 2 1 1 2 2 2 1 1 1 11 11 10 00 10 11 11 00 11 00 00 11 11 111x 1001 0kkk 0000 1kkk 1000 00xx 0000 01xx 0000 0000 110x 1010 kkkk kkkk kkkk 0110 kkkk kkkk kkkk 0000 kkkk 0000 0110 kkkk kkkk kkkk kkkk kkkk 0100 kkkk kkkk kkkk 1001 kkkk 1000 0011 kkkk kkkk c,dc,z z to , pd z to , pd c,dc,z z note 1: when an i/o register is modified as a function of itself ( e.g., movf portb, 1 ), the value used will be that value present on the pins themselves. for example, if the data latch is '1' for a pin configured as input and is driven low by an external device, the data will be written back with a '0'. 2: if this instruction is executed on the tmr0 register (and, where applicable, d = 1), the prescaler will be cleared if assigned to the timer0 module. 3: if program counter (pc) is modified or a conditional test is true, the instruction requires two cycles. the second cycle is executed as a nop.
1999 microchip technology inc. preliminary ds40300b-page 115 pic16f62x 15.1 instruction descriptions addlw add literal and w syntax: [ label ] addlw k operands: 0 k 255 operation: (w) + k ? (w) status affected: c, dc, z encoding: 11 111x kkkk kkkk description: the contents of the w register are added to the eight bit literal 'k' and the result is placed in the w register . words: 1 cycles: 1 example addlw 0x15 before instruction w = 0x10 after instruction w = 0x25 addwf add w and f syntax: [ label ] addwf f,d operands: 0 f 127 d ? [0,1] operation: (w) + (f) ? (dest) status affected: c, dc, z encoding: 00 0111 dfff ffff description: add the contents of the w register with register 'f'. if 'd' is 0 the result is stored in the w register. if 'd' is 1 the result is stored back in register 'f' . words: 1 cycles: 1 example addwf fsr, 0 before instruction w = 0x17 fsr = 0xc2 after instruction w = 0xd9 fsr = 0xc2 andlw and literal with w syntax: [ label ] andlw k operands: 0 k 255 operation: (w) .and. (k) ? (w) status affected: z encoding: 11 1001 kkkk kkkk description: the contents of w register are anded with the eight bit literal 'k'. the result is placed in the w register . words: 1 cycles: 1 example andlw 0x5f before instruction w = 0xa3 after instruction w = 0x03 andwf and w with f syntax: [ label ] andwf f,d operands: 0 f 127 d ? [0,1] operation: (w) .and. (f) ? (dest) status affected: z encoding: 00 0101 dfff ffff description: and the w register with register 'f'. if 'd' is 0 the result is stored in the w register. if 'd' is 1 the result is stored back in register 'f' . words: 1 cycles: 1 example andwf fsr, 1 before instruction w = 0x17 fsr = 0xc2 after instruction w = 0x17 fsr = 0x02
pic16f62x ds40300b-page 116 preliminary 1999 microchip technology inc. bcf bit clear f syntax: [ label ] bcf f,b operands: 0 f 127 0 b 7 operation: 0 ? (f) status affected: none encoding: 01 00bb bfff ffff description: bit 'b' in register 'f' is cleared . words: 1 cycles: 1 example bcf flag_reg, 7 before instruction flag_reg = 0xc7 after instruction flag_reg = 0x47 bsf bit set f syntax: [ label ] bsf f,b operands: 0 f 127 0 b 7 operation: 1 ? (f) status affected: none encoding: 01 01bb bfff ffff description: bit 'b' in register 'f' is set. words: 1 cycles: 1 example bsf flag_reg, 7 before instruction flag_reg = 0x0a after instruction flag_reg = 0x8a btfsc bit test, skip if clear syntax: [ label ] btfsc f,b operands: 0 f 127 0 b 7 operation: skip if (f) = 0 status affected: none encoding: 01 10bb bfff ffff description: if bit 'b' in register 'f' is '0' then the next instruction is skipped. if bit 'b' is '0' then the next instruction fetched during the current instruction execution is discarded, and a nop is executed instead, making this a two-cycle instruction . words: 1 cycles: 1(2) example here false true btfsc goto ? ? ? flag,1 process_code before instruction pc = address here after instruction if flag<1> = 0, pc = address true if flag<1>=1, pc = address false
1999 microchip technology inc. preliminary ds40300b-page 117 pic16f62x btfss bit test f, skip if set syntax: [ label ] btfss f,b operands: 0 f 127 0 b < 7 operation: skip if (f) = 1 status affected: none encoding: 01 11bb bfff ffff description: if bit 'b' in register 'f' is '1' then the next instruction is skipped. if bit 'b' is '1', then the next instruction fetched during the current instruction execution, is discarded and a nop is executed instead, making this a two-cycle instruction. words: 1 cycles: 1(2) example here false true btfss goto ? ? ? flag,1 process_code before instruction pc = address here after instruction if flag<1> = 0, pc = address false if flag<1> = 1, pc = address true call call subroutine syntax: [ label ] call k operands: 0 k 2047 operation: (pc)+ 1 ? tos, k ? pc<10:0>, (pclath<4:3>) ? pc<12:11> status affected: none encoding: 10 0kkk kkkk kkkk description: call subroutine. first, return address (pc+1) is pushed onto the stack. the eleven bit immediate address is loaded into pc bits <10:0>. the upper bits of the pc are loaded from pclath. call is a two-cycle instruction. words: 1 cycles: 2 example here call there before instruction pc = address here after instruction pc = address there tos = address here+1 clrf clear f syntax: [ label ] clrf f operands: 0 f 127 operation: 00h ? (f) 1 ? z status affected: z encoding: 00 0001 1fff ffff description: the contents of register 'f' are cleared and the z bit is set. words: 1 cycles: 1 example clrf flag_reg before instruction flag_reg = 0x5a after instruction flag_reg = 0x00 z=1 clrw clear w syntax: [ label ] clrw operands: none operation: 00h ? (w) 1 ? z status affected: z encoding: 00 0001 0000 0011 description: w register is cleared. zero bit (z) is set. words: 1 cycles: 1 example clrw before instruction w = 0x5a after instruction w = 0x00 z=1
pic16f62x ds40300b-page 118 preliminary 1999 microchip technology inc. clrwdt clear watchdog timer syntax: [ label ] clrwdt operands: none operation: 00h ? wdt 0 ? wdt prescaler, 1 ? to 1 ? pd status affected: to , pd encoding: 00 0000 0110 0100 description: clrwdt instruction resets the watchdog timer. it also resets the prescaler of the wdt. status bits to and pd are set. words: 1 cycles: 1 example clrwdt before instruction wdt counter = ? after instruction wdt counter = 0x00 wdt prescaler= 0 to =1 pd =1 comf complement f syntax: [ label ] comf f,d operands: 0 f 127 d ? [0,1] operation: (f ) ? (dest) status affected: z encoding: 00 1001 dfff ffff description: the contents of register 'f' are complemented. if 'd' is 0 the result is stored in w. if 'd' is 1 the result is stored back in register 'f'. words: 1 cycles: 1 example comf reg1,0 before instruction reg1 = 0x13 after instruction reg1 = 0x13 w = 0xec decf decrement f syntax: [ label ] decf f,d operands: 0 f 127 d ? [0,1] operation: (f) - 1 ? (dest) status affected: z encoding: 00 0011 dfff ffff description: decrement register 'f'. if 'd' is 0 the result is stored in the w register. if 'd' is 1 the result is stored back in register 'f' . words: 1 cycles: 1 example decf cnt, 1 before instruction cnt = 0x01 z=0 after instruction cnt = 0x00 z=1 decfsz decrement f, skip if 0 syntax: [ label ] decfsz f,d operands: 0 f 127 d ? [0,1] operation: (f) - 1 ? (dest); skip if result = 0 status affected: none encoding: 00 1011 dfff ffff description: the contents of register 'f' are decremented. if 'd' is 0 the result is placed in the w register. if 'd' is 1 the result is placed back in register 'f'. if the result is 0, the next instruction, which is already fetched, is discarded. a nop is executed instead making it a two-cycle instruction. words: 1 cycles: 1(2) example here decfsz cnt, 1 goto loop continue ? ? ? before instruction pc = address here after instruction cnt = cnt - 1 if cnt = 0, pc = address continue if cnt 1 0, pc = address here+1
1999 microchip technology inc. preliminary ds40300b-page 119 pic16f62x goto unconditional branch syntax: [ label ] goto k operands: 0 k 2047 operation: k ? pc<10:0> pclath<4:3> ? pc<12:11> status affected: none encoding: 10 1kkk kkkk kkkk description: goto is an unconditional branch. the eleven bit immediate value is loaded into pc bits <10:0>. the upper bits of pc are loaded from pclath<4:3>. goto is a two-cycle instruction. words: 1 cycles: 2 example goto there after instruction pc = address there incf increment f syntax: [ label ] incf f,d operands: 0 f 127 d ? [0,1] operation: (f) + 1 ? (dest) status affected: z encoding: 00 1010 dfff ffff description: the contents of register 'f' are incremented. if 'd' is 0 the result is placed in the w register. if 'd' is 1 the result is placed back in register 'f'. words: 1 cycles: 1 example incf cnt, 1 before instruction cnt = 0xff z=0 after instruction cnt = 0x00 z=1 incfsz increment f, skip if 0 syntax: [ label ] incfsz f,d operands: 0 f 127 d ? [0,1] operation: (f) + 1 ? (dest), skip if result = 0 status affected: none encoding: 00 1111 dfff ffff description: the contents of register 'f' are incremented. if 'd' is 0 the result is placed in the w register. if 'd' is 1 the result is placed back in register 'f'. if the result is 0, the next instruction, which is already fetched, is discarded. a nop is executed instead making it a two-cycle instruction . words: 1 cycles: 1(2) example here incfsz cnt, 1 goto loop continue ? ? ? before instruction pc = address here after instruction cnt = cnt + 1 if cnt= 0, pc = address continue if cnt 1 0, pc = address here +1 iorlw inclusive or literal with w syntax: [ label ] iorlw k operands: 0 k 255 operation: (w) .or. k ? (w) status affected: z encoding: 11 1000 kkkk kkkk description: the contents of the w register is o red with the eight bit literal 'k'. the result is placed in the w register . words: 1 cycles: 1 example iorlw 0x35 before instruction w = 0x9a after instruction w = 0xbf z=1
pic16f62x ds40300b-page 120 preliminary 1999 microchip technology inc. iorwf inclusive or w with f syntax: [ label ] iorwf f,d operands: 0 f 127 d ? [0,1] operation: (w) .or. (f) ? (dest) status affected: z encoding: 00 0100 dfff ffff description: inclusive or the w register with register 'f'. if 'd' is 0 the result is placed in the w register. if 'd' is 1 the result is placed back in register 'f'. words: 1 cycles: 1 example iorwf result, 0 before instruction result = 0x13 w = 0x91 after instruction result = 0x13 w = 0x93 z=1 movlw move literal to w syntax: [ label ] movlw k operands: 0 k 255 operation: k ? (w) status affected: none encoding: 11 00xx kkkk kkkk description: the eight bit literal 'k' is loaded into w register . t he dont cares will assemble as 0s. words: 1 cycles: 1 example movlw 0x5a after instruction w = 0x5a movf move f syntax: [ label ] movf f,d operands: 0 f 127 d ? [0,1] operation: (f) ? (dest) status affected: z encoding: 00 1000 dfff ffff description: the contents of register f is moved to a destination dependent upon the status of d. if d = 0, destination is w register. if d = 1, the destination is file register f itself. d = 1 is useful to test a file register since status flag z is affected. words: 1 cycles: 1 example movf fsr, 0 after instruction w = value in fsr register z= 1 movwf move w to f syntax: [ label ] movwf f operands: 0 f 127 operation: (w) ? (f) status affected: none encoding: 00 0000 1fff ffff description: move data from w register to register 'f' . words: 1 cycles: 1 example movwf option before instruction option = 0xff w = 0x4f after instruction option = 0x4f w = 0x4f
1999 microchip technology inc. preliminary ds40300b-page 121 pic16f62x nop no operation syntax: [ label ] nop operands: none operation: no operation status affected: none encoding: 00 0000 0xx0 0000 description: no operation. words: 1 cycles: 1 example nop option load option register syntax: [ label ] option operands: none operation: (w) ? option status affected: none encoding: 00 0000 0110 0010 description: the contents of the w register are loaded in the option register. this instruction is supported for code compatibility with pic16c5x products. since option is a readable/writable register, the user can directly address it. words: 1 cycles: 1 example to maintain upward compatibility with future picmicro ? products, do not use this instruction. retfie return from interrupt syntax: [ label ] retfie operands: none operation: tos ? pc, 1 ? gie status affected: none encoding: 00 0000 0000 1001 description: return from interrupt. stack is poped and top of stack (tos) is loaded in the pc. interrupts are enabled by setting global interrupt enable bit, gie (intcon<7>). this is a two-cycle instruction. words: 1 cycles: 2 example retfie after interrupt pc = tos gie = 1 retlw return with literal in w syntax: [ label ] retlw k operands: 0 k 255 operation: k ? (w); tos ? pc status affected: none encoding: 11 01xx kkkk kkkk description: the w register is loaded with the eight bit literal 'k'. the program counter is loaded from the top of the stack (the return address). this is a two-cycle instruction. words: 1 cycles: 2 example table call table ;w contains table ;offset value ? ;w now has table value ? ? addwf pc ;w = offset retlw k1 ;begin table retlw k2 ; ? ? ? retlw kn ; end of table before instruction w = 0x07 after instruction w = value of k8
pic16f62x ds40300b-page 122 preliminary 1999 microchip technology inc. return return from subroutine syntax: [ label ] return operands: none operation: tos ? pc status affected: none encoding: 00 0000 0000 1000 description: return from subroutine. the stack is poped and the top of the stack (tos) is loaded into the program counter. this is a two cycle instruction. words: 1 cycles: 2 example return after interrupt pc = tos rlf rotate left f through carry syntax: [ label ] rlf f,d operands: 0 f 127 d ? [0,1] operation: see description below status affected: c encoding: 00 1101 dfff ffff description: the contents of register 'f' are rotated one bit to the left through the carry flag. if 'd' is 0 the result is placed in the w register. if 'd' is 1 the result is stored back in register 'f'. words: 1 cycles: 1 example rlf reg1,0 before instruction reg1 = 1110 0110 c =0 after instruction reg1 = 1110 0110 w = 1100 1100 c =1 register f c rrf rotate right f through carry syntax: [ label ] rrf f,d operands: 0 f 127 d ? [0,1] operation: see description below status affected: c encoding: 00 1100 dfff ffff description: the contents of register 'f' are rotated one bit to the right through the carry flag. if 'd' is 0 the result is placed in the w register. if 'd' is 1 the result is placed back in register 'f'. words: 1 cycles: 1 example rrf reg1,0 before instruction reg1 = 1110 0110 c =0 after instruction reg1 = 1110 0110 w = 0111 0011 c =0 sleep syntax: [ label ] sleep operands: none operation: 00h ? wdt, 0 ? wdt prescaler, 1 ? to , 0 ? pd status affected: to , pd encoding: 00 0000 0110 0011 description: the power-down status bit, p d is cleared. time-out status bit, t o is set. watchdog timer and its prescaler are cleared. the processor is put into sleep mode with the oscillator stopped. see section 14.9 for more details. words: 1 cycles: 1 example: sleep register f c
1999 microchip technology inc. preliminary ds40300b-page 123 pic16f62x sublw subtract w from literal syntax: [ label ] sublw k operands: 0 k 255 operation: k - (w) ? ( w) status affected: c, dc, z encoding: 11 110x kkkk kkkk description: the w register is subtracted (2s com- plement method) from the eight bit literal 'k'. the result is placed in the w register. words: 1 cycles: 1 example 1: sublw 0x02 before instruction w= 1 c= ? after instruction w= 1 c = 1; result is positive example 2: before instruction w= 2 c= ? after instruction w= 0 c = 1; result is zero example 3: before instruction w= 3 c= ? after instruction w= 0xff c = 0; result is nega- tive subwf subtract w from f syntax: [ label ] subwf f,d operands: 0 f 127 d ? [0,1] operation: (f) - (w) ? ( dest) status affected: c, dc, z encoding: 00 0010 dfff ffff description: subtract (2s complement method) w register from register 'f'. if 'd' is 0 the result is stored in the w register. if 'd' is 1 the result is stored back in register 'f'. words: 1 cycles: 1 example 1: subwf reg1,1 before instruction reg1 = 3 w=2 c=? after instruction reg1 = 1 w=2 c = 1; result is positive example 2: before instruction reg1 = 2 w=2 c=? after instruction reg1 = 0 w=2 c = 1; result is zero example 3: before instruction reg1 = 1 w=2 c=? after instruction reg1 = 0xff w=2 c = 0; result is negative
pic16f62x ds40300b-page 124 preliminary 1999 microchip technology inc. swapf swap nibbles in f syntax: [ label ] swapf f,d operands: 0 f 127 d ? [0,1] operation: (f<3:0>) ? (dest<7:4>), (f<7:4>) ? (dest<3:0>) status affected: none encoding: 00 1110 dfff ffff description: the upper and lower nibbles of register 'f' are exchanged. if 'd' is 0 the result is placed in w register. if 'd' is 1 the result is placed in register 'f'. words: 1 cycles: 1 example swapf reg, 0 before instruction reg1 = 0xa5 after instruction reg1 = 0xa5 w = 0x5a tris load tris register syntax: [ label ] tris f operands: 5 f 7 operation: (w) ? tris register f; status affected: none encoding: 00 0000 0110 0fff description: the instruction is supported for code compatibility with the pic16c5x products. since tris registers are readable and writable, the user can directly address them. words: 1 cycles: 1 example to maintain upward compatibility with future picmicro ? products, do not use this instruction. xorlw exclusive or literal with w syntax: [ label ] xorlw k operands: 0 k 255 operation: (w) .xor. k ? ( w) status affected: z encoding: 11 1010 kkkk kkkk description: the contents of the w register are xored with the eight bit literal 'k'. the result is placed in the w register. words: 1 cycles: 1 example: xorlw 0xaf before instruction w= 0xb5 after instruction w = 0x1a xorwf exclusive or w with f syntax: [ label ] xorwf f,d operands: 0 f 127 d ? [0,1] operation: (w) .xor. (f) ? ( dest) status affected: z encoding: 00 0110 dfff ffff description: exclusive or the contents of the w register with register 'f'. if 'd' is 0 the result is stored in the w register. if 'd' is 1 the result is stored back in register 'f'. words: 1 cycles: 1 example xorwf reg 1 before instruction reg = 0xaf w = 0xb5 after instruction reg = 0x1a w = 0xb5
1999 microchip technology inc. preliminary ds40300b-page 125 pic16f62x 16.0 development support the picmicro ? microcontrollers are supported with a full range of hardware and software development tools: ? integrated development environment - mplab? ide software ? assemblers/compilers/linkers - mpasm assembler - mplab-c17 and mplab-c18 c compilers - mplink/mplib linker/librarian ? simulators - mplab-sim software simulator ?emulators - mplab-ice real-time in-circuit emulator - picmaster ? /picmaster-ce in-circuit emulator - icepic? ? in-circuit debugger - mplab-icd for pic16f877 ? device programmers -pro mate a ii universal programmer - picstart a plus entry-level prototype programmer ? low-cost demonstration boards - simice - picdem-1 - picdem-2 - picdem-3 - picdem-17 - seeval a -k ee l oq a 16.1 mplab integrated development environment software - the mplab ide software brings an ease of software development previously unseen in the 8-bit microcontroller market. mplab is a windows a -based application which contains: ? multiple functionality -editor - simulator - programmer (sold separately) - emulator (sold separately) ? a full featured editor ? a project manager ? customizable tool bar and key mapping ? a status bar ? on-line help mplab allows you to: ? edit your source files (either assembly or c) ? one touch assemble (or compile) and download to picmicro tools (automatically updates all project information) ? debug using: - source files - absolute listing file - object code the ability to use mplab with microchips simulator, mplab-sim, allows a consistent platform and the abil- ity to easily switch from the cost-effective simulator to the full featured emulator with minimal retraining. 16.2 mpasm assembler mpasm is a full featured universal macro assembler for all picmicro mcus. it can produce absolute code directly in the form of hex files for device program- mers, or it can generate relocatable objects for mplink. mpasm has a command line interface and a windows shell and can be used as a standalone application on a windows 3.x or greater system. mpasm generates relocatable object files, intel standard hex files, map files to detail memory usage and symbol reference, an absolute lst file which contains source lines and gen- erated machine code, and a cod file for mplab debugging. mpasm features include: ? mpasm and mplink are integrated into mplab projects. ? mpasm allows user defined macros to be created for streamlined assembly. ? mpasm allows conditional assembly for multi pur- pose source files. ? mpasm directives allow complete control over the assembly process. 16.3 mplab-c17 and mplab-c18 c compilers the mplab-c17 and mplab-c18 code development systems are complete ansi c compilers and inte- grated development environments for microchips pic17cxxx and pic18cxxx family of microcontrol- lers, respectively. these compilers provide powerful integration capabilities and ease of use not found with other compilers. for easier source level debugging, the compilers pro- vide symbol information that is compatible with the mplab ide memory display.
pic16f62x ds40300b-page 126 preliminary 1999 microchip technology inc. 16.4 mplink/mplib linker/librarian mplink is a relocatable linker for mpasm and mplab-c17 and mplab-c18. it can link relocatable objects from assembly or c source files along with pre- compiled libraries using directives from a linker script. mplib is a librarian for pre-compiled code to be used with mplink. when a routine from a library is called from another source file, only the modules that contains that routine will be linked in with the application. this allows large libraries to be used efficiently in many dif- ferent applications. mplib manages the creation and modification of library files. mplink features include: ? mplink works with mpasm and mplab-c17 and mplab-c18. ? mplink allows all memory areas to be defined as sections to provide link-time flexibility. mplib features include: ? mplib makes linking easier because single librar- ies can be included instead of many smaller files. ? mplib helps keep code maintainable by grouping related modules together. ? mplib commands allow libraries to be created and modules to be added, listed, replaced, deleted, or extracted. 16.5 mplab-sim software simulator the mplab-sim software simulator allows code development in a pc host environment by simulating the picmicro series microcontrollers on an instruction level. on any given instruction, the data areas can be examined or modified and stimuli can be applied from a file or user-defined key press to any of the pins. the execution can be performed in single step, execute until break, or trace mode. mplab-sim fully supports symbolic debugging using mplab-c17 and mplab-c18 and mpasm. the soft- ware simulator offers the flexibility to develop and debug code outside of the laboratory environment mak- ing it an excellent multi-project software development tool. 16.6 mplab-ice high performance universal in-circuit emulator with mplab ide the mplab-ice universal in-circuit emulator is intended to provide the product development engineer with a complete microcontroller design tool set for picmicro microcontrollers (mcus). software control of mplab-ice is provided by the mplab integrated development environment (ide), which allows editing, make and download, and source debugging from a single environment. interchangeable processor modules allow the system to be easily reconfigured for emulation of different pro- cessors. the universal architecture of the mplab-ice allows expansion to support new picmicro microcon- trollers. the mplab-ice emulator system has been designed as a real-time emulation system with advanced fea- tures that are generally found on more expensive devel- opment tools. the pc platform and microsoft ? windows 3.x/95/98 environment were chosen to best make these features available to you, the end user. mplab-ice 2000 is a full-featured emulator system with enhanced trace, trigger, and data monitoring fea- tures. both systems use the same processor modules and will operate across the full operating speed range of the picmicro mcu. 16.7 picmaster/picmaster ce the picmaster system from microchip technology is a full-featured, professional quality emulator system. this flexible in-circuit emulator provides a high-quality, universal platform for emulating microchip 8-bit picmicro microcontrollers (mcus). picmaster sys- tems are sold worldwide, with a ce compliant model available for european union (eu) countries. 16.8 icepic icepic is a low-cost in-circuit emulation solution for the microchip technology pic16c5x, pic16c6x, pic16c7x, and pic16cxxx families of 8-bit one-time- programmable (otp) microcontrollers. the modular system can support different subsets of pic16c5x or pic16cxxx products through the use of interchangeable personality modules or daughter boards. the emulator is capable of emulating without target application circuitry being present. 16.9 mplab-icd in-circuit debugger microchip's in-circuit debugger, mplab-icd, is a pow- erful, low-cost run-time development tool. this tool is based on the flash pic16f877 and can be used to develop for this and other picmicro microcontrollers from the pic16cxxx family. mplab-icd utilizes the in-circuit debugging capability built into the pic16f87x. this feature, along with microchip's in-cir- cuit serial programming protocol, offers cost-effective in-circuit flash programming and debugging from the graphical user interface of the mplab integrated development environment. this enables a designer to develop and debug source code by watching variables, single-stepping and setting break points. running at full speed enables testing hardware in real-time. the mplab-icd is also a programmer for the flash pic16f87x family.
1999 micr o chi p technology inc. prel i mina r y ds40300 b -page 127 pic16f62x 16 . 10 pro m a te i i univ e r sal p r ogr a mmer the pro m a te ii un i v er s al pro g ra m m e r is a f u l l -fe a - t u re d pr o gr a mmer c a pa b le of o p era t in g i n st a nd- a lo n e mo d e as we l l as pc- h os t ed mo d e. pro m a t e ii i s ce c o m p l i a nt. t h e p ro m a te i i h a s p ro g ramm a bl e v dd an d v pp s up p l i es whi c h al l o w s it t o v e r i f y pr o g rammed m e m o ry at v dd min an d v dd m a x for m a x i mu m r e l i ab i li t y . i t h a s a n lcd disp l a y for i nstructi o ns a n d e rror mess a ges, k e y s t o e n t e r c o mma n d s a n d a m o d u la r det a c h ab l e s o c k e t a s s e m b ly t o s u p p ort v ari o u s pa c k a g e t y p es . in s ta n d-a l o n e m o de th e p ro m a te ii c an re a d , v e ri f y or pr o g ram picm i c ro d e v i c e s. it c a n a l so s et c o d e - p r o t e ct b its i n th i s mo d e. 16 . 11 pi c s t a r t plus ent r y l e v e l d e velopment system t h e pics t a r t pro g ramm e r i s a n e a sy-to- u s e , l ow- cost pro t otype pr o gr a mme r . i t co n nects t o the pc v i a o ne o f th e com (rs- 2 32 ) ports. mplab i nte g rat e d d e ve l opme n t en v iro n m e n t s o ftwa r e ma k e s u s in g t h e p rogr a mme r s i mp l e a n d e f fi c ie n t. pics t a r t p l us sup p orts a l l picmicr o devices wi t h u p t o 40 p i n s. l a rg e r p i n c o u n t d e v i c e s s u c h a s t h e pic 1 6c9 2 x, a n d pic17c 7 6x may b e sup p ort e d w i th a n a d a p ter sock e t. pics t a r t pl u s i s ce c o m p li a nt. 1 6 . 1 2 s i m i ce e ntry - l e v e l ha r dw a re simulator simice i s a n e n tr y -l e v e l ha r dwar e d e v e l o pmen t s y s- t e m d esig n ed t o o p er a te i n a pc- b ased e nviro n m e nt w i th microchi p s s i m u l a tor mplab-sim. b o th simice a nd mplab-sim run u nd e r microch i p t e c h no l ogy s mplab i n te g rat e d devel o pmen t e n v i ro n me n t (ide) s o ftw a re. sp e c i fi c a l l y , simice p ro v i d es h a rdwa r e sim- ulation for microchip s pic12c5xx , pic12ce5xx, and pic 1 6c5x f a m i li e s of picmicro 8-b i t microco n tro l lers. simice works i n con j unct i on w i th mplab-sim to p ro- v i de n o n -r e a l - t i m e i / o p o rt e m u l a t i o n. s i m ice e n a b l e s a deve l op e r to r u n simul a tor cod e for d rivin g th e tar g et s y s tem. i n a d di t io n , t h e t a rge t s y st e m ca n pr o v i d e in p u t t o t h e simu l at o r cod e . t h is cap a bi l ity a ll o w s fo r simp l e a nd i n ter a ct i v e d eb u gg i n g w i tho u t ha v i n g to m a nu a l l y g en e rat e mp l ab-sim stimu l us fi l es . sim i ce i s a va l u- a b l e d eb u gg i ng t o ol for e n try- l e v e l s y s tem d e v e l o p- m e nt. 1 6.13 pi c dem-1 l o w-cost picmic r o demonstration boa r d t h e picdem- 1 i s a s i m p le b o ard whi c h d e m o ns t rat e s t h e ca p a b il i ti e s of se v er a l of m i cr o ch i p s m i c r oc o ntr o l - l ers. th e m i cr o co n tro l l e rs sup p ort e d ar e : pic1 6 c5x (p i c16c54 to pic16c58a), pic16c61 , p i c16c62x, pic 1 6c7 1 , p i c 1 6c8x , pic 1 7c4 2 , pic 1 7c4 3 a n d pic 1 7c4 4 . al l n ecessary h a rdwar e an d so f tware i s i n c lu d ed t o r u n ba s i c demo pr o g r a m s . th e u s e rs c a n p r o g r a m t h e s a m p l e m i c r o c o ntro l ler s provide d with th e picdem- 1 board, on a pr o m a t e i i or pics t a r t -plu s progra m me r , and easil y te s t firm- ware. the user can als o connect th e picdem-1 board t o th e mplab-ice emulator and down l o a d t h e f i rmw a re t o t h e emu l at o r fo r testi n g. a d d i tio n a l pro t o- t y p e a re a i s a va i l a bl e f o r th e u s er to b u i l d s o m e ad d i- t i on a l ha r dwar e a nd c o n n ec t i t t o the mi c ro c ont r o l l er sock e t(s) . s o m e o f t h e f e at u re s i nc l u d e a n rs-2 3 2 i nter f ace, a pot e nt i omet e r f o r simu l at e d an a lo g i np u t, p u s h -b u tto n sw i tc h e s a n d e i g h t led s c o n n ec t e d to po r tb. 16 . 14 p i cde m -2 low-cost pic1 6 cxx demonstration boa r d t h e picdem-2 i s a simp l e d e m o nstrat i o n bo a rd t h at sup p orts t h e pic1 6 c62 , pic 1 6c6 4 , p i c16c 6 5, pic 1 6c7 3 a n d pic 1 6c7 4 microcon t r o l l e r s . a l l t h e n e c e s s ar y har d ware a nd s o ftw a re i s in c l u de d to r u n t he b a s i c demo n st r a ti o n pr o g rams . t h e u s er c an p rog r am t he s a mp l e m i cr o c o n tr o ll e rs p ro v id e d wi t h th e picdem-2 bo a rd, o n a pro m a t e i i p ro- g r a m m e r o r pics t a r t -p l us, an d easi l y test f i rmwa r e. t h e mplab- i ce emu l ato r m a y a lso b e u s e d wi t h t h e picdem- 2 bo a rd t o t e st firmwar e . ad d it i on a l p rot o t y p e a r e a has b ee n pr o v i de d t o t h e u s e r f o r a d di n g ad d i- t i on a l h a rdwar e an d c o nn e ct i n g i t to t h e mi c ro c ont r o l l er sock e t(s) . s o me o f t h e fe a tur e s incl u de a rs-2 3 2 in t er- f a c e , p ush-b u tt o n swi t ch e s , a p ote n ti o m e te r fo r simu- l ate d a na l o g in p ut , a seri a l eeprom t o d emonstr a te u s a g e o f t h e i 2 c b us a n d sep a rat e h e ad e r s for co n nec- t i o n to a n l cd m o du l e a nd a k e y p ad. 16 . 1 5 p i cde m -3 low-cost pic1 6 cxxx demonstration boa r d t h e picdem-3 i s a simp l e d e m o nstrat i o n bo a rd t h at s u p p o r t s t h e p i c 1 6 c 9 2 3 a n d p i c 1 6 c9 2 4 in t h e p l cc p a c k a g e . i t w i l l a l so s u p p ort f u t u re 4 4 -p i n p l cc mi c ro c on t rol l er s wit h a lcd mo d u l e . al l th e n e ce s - sary har d war e an d s o ftwar e is incl u de d to r u n t h e b a s i c d e mon s tr a tio n pr o g rams . th e u s er c an p ro- g r am t h e samp l e m i cr o c o n tr o ll e rs pr o v i de d w i th t h e p i cdem- 3 bo a rd , o n a pro m a te i i pr o gram- m e r o r pics t a r t pl u s wit h a n a da p te r s o cket , a n d e a s i ly test f irmware . th e mplab-ic e emul a t o r m a y a l s o be u s e d wit h th e picdem- 3 bo a rd t o test firm- war e . ad d it i o n al p r o t o ty p e ar e a h a s be e n pro v id e d t o t h e us e r f o r a d di n g hardw a re a nd co n ne c t i ng it t o t h e mi c r o co n tro l ler s o ck e t(s). s o me of the fe a tur e s i n c lu d e a n rs- 2 3 2 in t e rf a ce , p u s h -bu t to n sw i tc h e s , a p o ten t i- ome t er f o r s i m u la t ed a na l o g in p u t, a th e rm i s t or a n d sep a rat e h ea d ers f or c o nn e ct i on t o a n extern a l lcd mod u l e a n d a k e yp a d . al s o pr o v i de d o n t h e picdem-3 b o ar d i s an lcd p a ne l , w i th 4 c o mmo n s an d 1 2 s e g- men t s , th a t i s c a p ab l e of d i s p l a y i n g time , temp e rat u re a n d d a y o f the w e ek . t he picdem-3 p ro v id e s a n ad d i- t i on a l rs-2 3 2 in t erf a c e a nd w i nd o ws 3 . 1 s o ftwar e f or show i ng t he d emult i p l exed l cd si g na l s o n a pc. a sim- p l e s e ria l i nt e rface al l ows t h e u s e r t o co n str u ct a h a rd- war e d e m u lt i pl e x e r fo r th e lcd sig n als.
pic16f62x ds403 0 0b-page 128 prel i mina r y 1999 mi c rochip te c hnology inc. 16 . 16 pi c de m - 1 7 t h e p i cd e m- 1 7 is a n e va l u a tio n b o ar d th a t d e m o n- s t r a t e s t h e c a p a b i l i t i e s o f s e v e r a l m i c r o c h i p m i c ro c o n - tr o l l ers, i n c l ud i n g pic1 7 c75 2 , pic 1 7c7 5 6, pic 1 7c7 6 2, an d p i c 1 7c7 6 6. al l n ec e ssary h ardw a re i s i n c lu d e d to r u n b a s i c d e mo p rogr a m s , w h ic h ar e s u p- p li ed on a 3 .5- i n ch d i s k . a p ro g r a mm e d s a m p le is i n c lu d ed, a n d the u s er m a y er a se i t a n d pro g ram i t w i th t h e ot h e r samp l e pro g rams usin g t h e pro m a te ii or pics t a r t p l u s d e v i c e p rog r ammer s an d e a s il y d eb u g a nd t e s t th e s a m p l e co d e . in a dd i ti o n , picdem-1 7 s u p- p orts d o wn-l o ad i n g of p rogr a ms t o a n d execut i n g ou t of e xt e rna l f lash memory o n bo a rd . th e picdem-1 7 i s a lso usab l e wit h th e mpla b -ice or picmaster emu- l a to r , a n d al l o f t h e s a mpl e p rogr a m s c a n b e ru n a n d mo d ifi e d u s i n g e i th e r emul a to r . add i ti o na l l y , a ge n er- o u s pro t otyp e are a is ava i la b l e for u s e r h a rdwar e . 16.17 see v al e v aluation and p r ogramming s y stem t h e see v al seeprom desig n e r s k i t s u pp o rts a l l microchi p 2-wir e an d 3-wir e ser i al eeproms. t h e kit i n c lu d e s e v er y th i ng ne c e s s a ry to rea d , wr i te, era s e or p rogr a m speci a l fe a t ur e s o f a ny microch i p seeprom p rod u ct incl u di n g smar t ser i al s ? an d s e c u re s e r i al s . t h e t ot a l en d ur a nc e ? disk i s i nclu d ed t o a i d i n tra d e- o f f a na l y s i s a n d r e l i ab i li t y c a l c u l ati o n s . th e tot a l k i t c a n si g nif i c a nt l y r e duce t i m e -to-marke t an d resul t in a n o p t i m i z e d s yst e m. 16.18 k ee l oq e v aluation and p r ogramming t ools k ee l oq e v a lu a ti o n a n d p rogr a mmi n g t o ol s s u p p ort microchips hcs secu r e data products. the hcs eval- u a ti o n k i t in c l u de s a n lcd d i s p la y t o s h ow c ha n gi n g c od e s , a de c o d e r t o de c od e tr a n s m i s s i o n s , a n d a p ro- g ramm i ng i nt e rface t o p r ogr a m t est tr a nsmi t ters.
1999 microchip technology inc. preliminary ds40300b-page 129 pic16f62x table 16-1: development tools from microchip pic12cxxx pic14000 pic16c5x pic16c6x pic16cxxx pic16f62x pic16c7x pic16c7xx pic16c8x pic16f8xx pic16c9xx pic17c4x pic17c7xx pic18cxx2 24cxx/ 25cxx/ 93cxx hcsxxx mcrfxxx mcp2510 software tools mplab ? integrated development environment mplab ? c17 compiler mplab ? c18 compiler mpasm/mplink emulators mplab ?-ice ** picmaster/picmaster-ce icepic ? low-cost in-circuit emulator debugger mplab-icd in-circuit debugger * * programmers picstart a plus low-cost universal dev. kit ** pro mate a ii universal programmer ** demo boards and eval kits simice picdem-1 ? picdem-2 ? ? picdem-3 picdem-14a picdem-17 k ee l oq ? evaluation kit k ee l oq transponder kit microid ? programmers kit 125 khz microid developers kit 125 khz anticollision microid developers kit 13.56 mhz anticollision microid developers kit mcp2510 can developers kit * contact the microchip technology inc. web site at www.microchip.com for information on how to use the mplab-icd in-circuit deb ugger (dv164001) with pic16c62, 63, 64, 65, 72, 73, 74, 76, 77 ** contact microchip technology inc. for availability date. ? development tool is available on select devices.
pic16f62x ds40300b-page 130 preliminary 1999 microchip technology inc. notes:
1999 microchip technology inc. preliminary ds40300b-page 131 pic16f62x 17.0 electrical specifications absolute maximum ratings ? ambient temperature under bias................................................................................................. ................ -40 to +125c storage temperature ............................................................................................................ .................. -65c to +150c voltage on v dd with respect to v ss ........................................................................................................... -0.3 to +6.5v voltage on mclr and ra4 with respect to v ss ..........................................................................................-0.3 to +14v voltage on all other pins with respect to v ss ....................................................................................-0.3v to v dd + 0.3v total power dissipation (note 1)............................................................................................... ............................800 mw maximum current out of v ss pin ........................................................................................................................... 300 ma maximum current into v dd pin ........................................................................................................................... ...250 ma input clamp current, i ik (v i < 0 or v i > v dd ) ..................................................................................................................... 20 ma output clamp current, i ok (vo < 0 or vo >v dd ) ............................................................................................................... 20 ma maximum output current sunk by any i/o pin..................................................................................... .....................25 ma maximum output current sourced by any i/o pin .................................................................................. ..................25 ma maximum current sunk by porta and portb....................................................................................................200 ma maximum current sourced by porta and portb ..................................................................................... .........200 ma note 1: power dissipation is calculated as follows: pdis = v dd x {i dd - ? i oh } + ? {(v dd -v oh ) x i oh } + ? (v o l x i ol ) ? notice : stresses above those listed under "absolute maximum ratings" may cause permanent damage to the device. this is a stress rating only and functional operation of the device at those or any other conditions above those indicated in the operation listings of this specification is not implied. exposure to maximum rating conditions for extended periods may affect device reliability. note: voltage spikes below v ss at the mclr pin, inducing currents greater than 80 ma, may cause latch-up. thus, a series resistor of 50-100 w should be used when applying a "low" level to the mclr pin rather than pulling this pin directly to v ss .
pic16f62x ds40300b-page 132 preliminary 1999 microchip technology inc. figure 17-1: pic16f62x voltage-frequency graph, 0 c t a +70 c figure 17-2: pic16f62x voltage-frequency graph, -40 c t a < 0 c, +70 c < ta 85 c 6.0 2.5 4.0 3.0 0 3.5 4.5 5.0 5.5 410 frequency (mhz) v dd 20 (volts) 25 note 1: the shaded region indicates the permissible combinations of voltage and frequency. 6.0 2.5 4.0 3.0 0 3.5 4.5 5.0 5.5 410 frequency (mhz) v dd 20 (volts) 25 2.0 note 1: the shaded region indicates the permissible combinations of voltage and frequency.
1999 microchip technology inc. preliminary ds40300b-page 133 pic16f62x figure 17-3: pic16lf62x voltage-frequency graph, 0 c t a +70 c figure 17-4: pic16lf62x voltage-frequency graph, -40 c t a < 0 c, +70 c < ta 85 c 6.0 2.5 4.0 3.0 0 3.5 4.5 5.0 5.5 410 frequency (mhz) v dd 20 (volts) 25 2.0 note 1: the shaded region indicates the permissible combinations of voltage and frequency. 6.0 2.5 4.0 3.0 0 3.5 4.5 5.0 5.5 410 frequency (mhz) v dd 20 (volts) 25 2.0 note 1: the shaded region indicates the permissible combinations of voltage and frequency.
pic16f62x ds40300b-page 134 preliminary 1999 microchip technology inc. 17.1 dc characteristics: pic16f62x-04 (commercial, industrial, extended) pic16f62x-20 (commercial, industrial, extended) standard operating conditions (unless otherwise stated) operating temperature C40 c t a +85 c for industrial and 0 c t a +70 c for commercial and C40 c t a +125 c for extended param no. sym characteristic min typ? max units conditions d001 v dd supply voltage 3.0 - 5.5 v d002 v dr ram data retention voltage (note 1) C 1.5* C v device in sleep mode d003 v por v dd start voltage to ensure power-on reset C vss C v see section on power-on reset for details d004 s vdd v dd rise rate to ensure power-on reset 0.05* C C v/ms see section on power-on reset for details d005 v bod brown-out detect voltage 3.7 3.7 4.0 4.0 4.3 4.4 v boden configuration bit is cleared (extended) d010 d013 i dd supply current (note 2, 5) C C C C C 4.0 C C 0.7 7.0 6.0 2.0 ma ma ma ma f osc = 4.0 mh z , v dd = 3.0 f osc = 20.0 mhz, v dd = 5.5 f osc = 20.0 mhz, v dd = 4.5 f osc = 10.0 mhz, v dd = 3.0 d020 i pd power down current (note 3) C C C C C C C C 2.2 5.0 9.0 15.0 m a m a m a m a v dd = 3.0 v dd = 4.5 v dd = 5.5 v dd = 5.5 extended d023 d i wdt d i bod d i comp d i vref wdt current (note 4) brown-out detect current (note 4) comparator current for each comparator (note 4) v ref current (note 4) C C C C 6.0 75 30 20 25 125 50 135 m a m a m a m a m a v dd =4.0v (125 c) bod enabled, v dd = 5.0v v dd = 4.0v v dd = 4.0v 1a f osc lp oscillator operating frequency intrc oscillator operating frequency xt oscillator operating frequency hs oscillator operating frequency 0 C 0 0 C C C C 200 4 4 20 khz mhz mhz mhz all temperatures all temperatures all temperatures all temperatures * these parameters are characterized but not tested. ? data in "typ" column is at 5.0v, 25 c, unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: this is the limit to which v dd can be lowered in sleep mode without losing ram data. 2: the supply current is mainly a function of the operating voltage and frequency. other factors such as i/o pin loading and switching rate, oscillator type, internal code execution pattern, and temperature also have an impact on the current con- sumption. the test conditions for all i dd measurements in active operation mode are: osc1 = external square wave, from rail to rail; all i/o pins tri-stated, pulled to v dd , mclr = v dd ; wdt enabled/disabled as specified. 3: the power down current in sleep mode does not depend on the oscillator type. power down current is measured with the part in sleep mode, with all i/o pins in hi-impedance state and tied to v dd or v ss . 4: the d current is the additional current consumed when this peripheral is enabled. this current should be added to the base i dd or i pd measurement. 5: for rc osc configuration, current through rext is not included. the current through the resistor can be estimated by the formula ir = v dd /2rext (ma) with rext in k w.
1999 microchip technology inc. preliminary ds40300b-page 135 pic16f62x 17.2 dc characteristics: pic16lf62x-04 (commercial, industrial, extended) standard operating conditions (unless otherwise stated) operating temperature C40c ta +85c for industrial and 0c ta +70c for commercial and C40c ta +125c for extended operating voltage v dd range as described in dc spec table 17.1 and table 12-2 param no. sym characteristic min typ? max units conditions d001 v dd supply voltage 2.0 - 5.5 v d002 v dr ram data retention voltage (note 1) C 1.5* C v device in sleep mode d003 v por v dd start voltage to ensure power-on reset Cv ss C v see section on power-on reset for details d004 s vdd v dd rise rate to ensure power-on reset 0.05* C C v/ms see section on power-on reset for details d005 v bod brown-out detect voltage 3.7 4.0 4.3 v boden configuration bit is cleared d010 d013 i dd supply current (note 2, 5) C C C C C 4.0 C C 0.6 7.0 6.0 2.0 ma ma ma ma f osc = 4.0 mh z , v dd = 2.5 f osc = 20.0 mhz, v dd = 5.5 f osc = 20.0 mhz, v dd = 4.5 f osc = 10.0 mhz, v dd = 3.0 d020 i pd power down current (note 2) C C C C C C C C 2.0 2.2 5.0 9.0 15.0 m a m a m a m a m a v dd = 2.5 v dd = 3.0 v dd = 4.5 v dd = 5.5 v dd = 5.5 extended d023 d i wdt d i bod d i comp d i vref wdt current (note 4) brown-out detect current (note 4) comparator current for each comparator (note 4) v ref current (note 4) C C C C 6.0 75 30 15 125 50 135 m a m a m a m a v dd =3.0v bod enabled, v dd = 5.0v v dd = 3.0v v dd = 3.0v 1a f osc lp oscillator operating frequency intrc oscillator operating frequency xt oscillator operating frequency hs oscillator operating frequency 0 C 0 0 C C C C 200 4 4 20 khz mhz mhz mhz all temperatures all temperatures all temperatures all temperatures * these parameters are characterized but not tested. ? data in "typ" column is at 5.0v, 25 c, unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: this is the limit to which v dd can be lowered in sleep mode without losing ram data. 2: the supply current is mainly a function of the operating voltage and frequency. other factors such as i/o pin loading and switching rate, oscillator type, internal code execution pattern, and temperature also have an impact on the current consump- tion. the test conditions for all idd measurements in active operation mode are: osc1=external square wave, from rail to rail; all i/o pins tristated, pulled to v dd , mclr = v dd ; wdt enabled/disabled as specified. 3: the power down current in sleep mode does not depend on the oscillator type. power down current is measured with the part in sleep mode, with all i/o pins in hi-impedance state and tied to v dd to v ss . 4: the d current is the additional current consumed when this peripheral is enabled. this current should be added to the base i dd or i pd measurement. 5: for rc osc configuration, current through rext is not included. the current through the resistor can be estimated by the for- mula ir = v dd /2rext (ma) with rext in k w.
pic16f62x ds40300b-page 136 preliminary 1999 microchip technology inc. 17.3 dc characteristics: pic16f62x (commercial, industrial, extended) pic16lf62x (commercial, industrial, extended) standard operating conditions (unless otherwise stated) operating temperature C40c ta +85c for industrial and 0c ta +70c for commercial and C40c ta +125c for extended operating voltage v dd range as described in dc spec table 17.1 and table 12-2 param. no. sym characteristic min typ? max unit conditions v il input low voltage i/o ports d030 with ttl buffer v ss -0.8v 0.15v dd vv dd = 4.5v to 5.5v otherwise d031 with schmitt trigger input v ss 0.2v dd v d032 mclr , ra4/t0cki,osc1 (in er mode) vss - 0.2v dd v note1 d033 osc1 (in xt and hs) vss - 0.3v dd v osc1 (in lp) vss - 0.6v dd -1.0 v v ih input high voltage i/o ports - d040 with ttl buffer 2.0v .25v dd + 0.8v -v dd v dd vv dd = 4.5v to 5.5v otherwise d041 with schmitt trigger input 0.8v dd v dd d042 mclr ra4/t0cki 0.8v dd -v dd v d043 d043a osc1 (xt, hs and lp) osc1 (in er mode) 0.7v dd 0.9v dd -v dd v note1 d070 i purb portb weak pull-up current 50 200 400 m av dd = 5.0v, v pin = v ss i il input leakage current (notes 2, 3) i/o ports (except porta) 1.0 m av ss v pin v dd , pin at hi-impedance d060 porta - - 0.5 m avss v pin v dd , pin at hi-impedance d061 ra4/t0cki - - 1.0 m avss v pin v dd d063 osc1, mclr -- 5.0 m avss v pin v dd , xt, hs and lp osc configuration v ol output low voltage d080 i/o ports - - 0.6 v i ol =8.5 ma, v dd =4.5v, -40 to +85 c --0.6vi ol =7.0 ma, v dd =4.5v, +125 c d083 osc2/clkout (er only) - - 0.6 v i ol =1.6 ma, v dd =4.5v, -40 to +85 c --0.6vi ol =1.2 ma, v dd =4.5v, +125 c v oh output high voltage (note 3) d090 i/o ports (except ra4) v dd -0.7 - - v i oh =-3.0 ma, v dd =4.5v, -40 to +85 c v dd -0.7 - - v i oh =-2.5 ma, v dd =4.5v, +125 c d092 osc2/clkout (er only) v dd -0.7 - - v i oh =-1.3 ma, v dd =4.5v, -40 to +85 c v dd -0.7 - - v i oh =-1.0 ma, v dd =4.5v, +125 c *d150 v od open-drain high voltage - 8.5* v ra4 pin pic16f62x, pic16lf62x capacitive loading specs on output pins d100 c osc2 osc2 pin - 15 pf in xt, hs and lp modes when external clock used to drive osc1. d101 cio all i/o pins/osc2 (in er mode) - 50 pf * these parameters are characterized but not tested. ? data in typ column is at 5.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: in er oscillator configuration, the osc1 pin is a schmitt trigger input. it is not recommended that the pic16f62x be driven wi th external clock in er mode. 2: the leakage current on the mclr pin is strongly dependent on applied voltage level. the specified levels represent normal operat- ing conditions. higher leakage current may be measured at different input voltages. 3: negative current is defined as coming out of the pin.
1999 microchip technology inc. preliminary ds40300b-page 137 pic16f62x table 17-1: comparator specifications table 17-2: voltage reference specifications operating conditions: 3.0v < v dd < 5.5v, -40c < t a < +125c, unless otherwise stated. param no. characteristics sym min typ max units comments d300 input offset voltage v ioff - 5.0 10 mv d301 input common mode voltage* v icm 0-v dd - 1.5 v d302 common mode rejection ratio* cmrr 55 - - db 300 300a response time (1)* t resp -150400 600 ns ns 16f62x 16lf62x 301 comparator mode change to output valid* t mc 2 ov --10 m s * these parameters are characterized but not tested. response time measured with one comparator input at (v dd - 1.5)/2 while the other input transitions from v ss to v dd . operating conditions: 3.0v < v dd < 5.5v, -40 c < t a < +125 c, unless otherwise stated. spec no. characteristics sym min typ max units comments d310 resolution v res v dd /24 - v dd /32 lsb d311 absolute accuracy vr aa - - - - 1/4 1/2 lsb lsb low range (vrr = 1) high range (vrr = 0) d312 unit resistor value (r)* vr ur -2k- w 310 settling time (1) * t set - - 10 m s * these parameters are characterized but not tested. settling time measured while vrr = 1 and vr<3:0> transitions from 0000 to 1111 .
pic16f62x ds40300b-page 138 preliminary 1999 microchip technology inc. 17.4 timing parameter symbology the timing parameter symbols have been created with one of the following formats: figure 17-5: load conditions table 17-3: dc characteristics: pic16f62x, pic16lf62x 1. tpps2pps 2. tpps t f frequency t time lowercase subscripts (pp) and their meanings: pp ck clkout osc osc1 io i/o port t0 t0cki mc mclr uppercase letters and their meanings: s f fall p period hhigh rrise i invalid (hi-impedance) v valid l low z hi-impedance dc characteristics standard operating conditions (unless otherwise stated) parameter no. sym characteristic min typ? max units conditions data eeprom memory d120 ed endurance 1m * 10m e/w25 c at 5v d121 vdrw v dd for read/write v min 5.5vv min = minimum operating voltage d122 tdew erase/write cycle time 4 8 * ms program flash memory d130 ep endurance 1000 * 10000 e/w d131 vpr v dd for read vmin 5.5 v v min = minimum operating voltage d132 vpew v dd for erase/write 4.5 5.5 v d133 tpew erase/write cycle time 4 8 * ms * these parameters are characterized but not tested. ? data in typ column is at 5.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. v dd /2 c l r l pin pin v ss v ss c l r l =464 w c l = 50 pf for all pins except osc2 15 pf for osc2 output load condition 1 load condition 2
1999 microchip technology inc. preliminary ds40300b-page 139 pic16f62x 17.5 timing diagrams and specifications figure 17-6: external clock timing table 17-4: external clock timing requirements parameter no. sym characteristic min typ? max units conditions fosc external clkin frequency (note 1) dc 4 mhz xt and er osc mode, v dd =5.0v dc 20 mhz hs osc mode dc 200 khz lp osc mode oscillator frequency (note 1) 4 mhz er osc mode, v dd =5.0v 0.1 4 mhz xt osc mode 1 20 200 mhz khz hs osc mode lp osc mode 4 mhz intrc mode (fast) 37 khz intrc mode (slow) 1 tosc external clkin period (note 1) 250 ns xt and er osc mode 50 ns hs osc mode 5 m slp osc mode oscillator period (note 1) 250 ns er osc mode 250 10,000 ns xt osc mode 50 1,000 ns hs osc mode 5 m slp osc mode 250 ns intrc mode (fast) 27 m s intrc mode (slow) 2 tcy instruction cycle time (note 1) 1.0 t cy dc ns t cy = 4/f osc 3 tos l, tos h external clkin (osc1) high external clkin low 100 * ns xt oscillator, t osc l/h duty cycle 4 intrc internal calibrated er 3.65 4.00 4.28 mhz v dd = 5.0v 5 er external biased er frequency 10khz 8mhz v dd = 5.0v osc1 clkout q4 q1 q2 q3 q4 q1 133 44 2
pic16f62x ds40300b-page 140 preliminary 1999 microchip technology inc. figure 17-7: clkout and i/o timing table 17-5: clkout and i/o timing requirements parameter no. sym characteristic min typ? max units 10 tosh2ckl osc1 - to clkout 16f62x 75 200 ns 10a 16lf62x 400 ns 11 tosh2ckh osc1 - to clkout - 16f62x 75 200 ns 11a 16lf62x 400 ns 12 tckr clkout rise time 16f62x 35 100 ns 12a 16lf62x 200 ns 13 tckf clkout fall time 16f62x 35 100 ns 13a 16lf62x 200 ns 14 tckl2iov clkout to port out valid 20 ns 15 tiov2ckh port in valid before 16f62x to s c +200 ns ns clkout - 16lf62x to s c =400 ns ns 16 tckh2ioi port in hold after clkout - 0 ns 17 tosh2iov osc1 - (q1 cycle) to 16f62x 50 150 * ns port out valid 16lf62x 300 ns 18 tosh2ioi osc1 - (q2 cycle) to port input invalid (i/o in hold time) 100 200 ns osc1 clkout i/o pin (input) i/o pin (output) q4 q1 q2 q3 10 13 14 17 20, 21 22 23 19 18 15 11 12 16 old value new value
1999 microchip technology inc. preliminary ds40300b-page 141 pic16f62x figure 17-8: reset, watchdog timer, oscillator start-up timer and power-up timer timing figure 17-9: brown-out detect timing table 17-6: reset, watchdog timer, oscillator start-up timer and power-up timer requirements parameter no. sym characteristic min typ? max unit s conditions 30 tmcl mclr pulse width (low) 2000 tbd tbd tbd ns ms v dd = 5v, -40c to +85c extended temperature 31 twdt watchdog timer time-out period (no prescaler) 7 tbd 18 tbd 33 tbd ms ms v dd = 5v, -40c to +85c extended temperature 32 tost oscillation start-up timer period 1024t osc t osc = osc1 period 33* tpwrt power up timer period 28 tbd 72 tbd 132 tbd ms ms v dd = 5v, -40c to +85c 34 t ioz i/o hi-impedance from mclr low or watchdog timer reset 2.0 m s 35 t bod brown-out detect pulse width 100 m sv dd b vdd (d005) v dd mclr internal por pwrt timeout osc timeout internal reset watchdog timer reset 33 32 30 31 34 i/o pins 34 v dd bv dd 35
pic16f62x ds40300b-page 142 preliminary 1999 microchip technology inc. figure 17-10: timer0 and timer1 external clock timings 46 47 45 48 41 42 40 ra4/t0cki rb6/t1oso/t1cki tmr0 or tmr1
1999 microchip technology inc. preliminary ds40300b-page 143 pic16f62x table 17-7: timer0 and timer1 external clock requirements figure 17-11: capture/compare/pwm timings param no. sym characteristic min typ? max units conditions 40* tt0h t0cki high pulse width no prescaler 0.5t cy + 20 ns with prescaler 10 ns 41* tt0l t0cki low pulse width no prescaler 0.5t cy + 20 ns with prescaler 10 ns 42* tt0p t0cki period greater of: t cy + 40 n ns n = prescale value (2, 4, ..., 256) 45* tt1h t1cki high time synchronous, no prescaler 0.5t cy + 20 ns synchronous, with prescaler 16f62x 15 ns 16lf62x 25 ns asynchronous 16f62x 30 ns 16lf62x 50 ns 46* tt1l t1cki low time synchronous, no prescaler 0.5t cy + 20 ns synchronous, with prescaler 16f62x 15 ns 16lf62x 25 ns asynchronous 16f62x 30 ns 16lf62x 50 ns 47* tt1p t1cki input period synchronous 16f62x greater of: t cy + 40 n ns n = prescale value (1, 2, 4, 8) 16lf62x greater of: t cy + 40 n asynchronous 16f62x 60 ns 16lf62x 100 ns ft1 timer1 oscillator input frequency range (oscillator enabled by setting bit t1oscen) dc 200 khz 48 tckeztmr1 delay from external clock edge to timer increment 2tosc 7tos c * these parameters are characterized but not tested. ?data in "typ" column is at 5v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. (capture mode) 50 51 52 53 54 rb3/ccp1 (compare or pwm mode) rb3/ccp1
pic16f62x ds40300b-page 144 preliminary 1999 microchip technology inc. table 17-8: capture/compare/pwm requirements figure 17-12: timer0 clock timing table 17-9: timer0 clock requirements param no. sym characteristic min typ? max units conditions 50* tccl ccp input low time no prescaler 0.5t cy + 20 ns with prescaler 16f62x 10 ns 16lf62x 20 ns 51* tcch ccp input high time no prescaler 0.5t cy + 20 ns with prescaler 16f62x 10 ns 16lf62x 20 ns 52* tccp ccp input period 3t cy + 40 n ns n = prescale value (1,4 or 16) 53* tccr ccp output rise time 16f62x 10 25 ns 16lf62x 25 45 ns 54* tccf ccp output fall time 16f62x 10 25 ns 16lf62x 25 45 ns * these parameters are characterized but not tested. ?data in "typ" column is at 5v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. parameter no. sym characteristic min typ? max units conditions 40 tt0h t0cki high pulse width no prescaler 0.5 t cy + 20* ns with prescaler 10* ns 41 tt0l t0cki low pulse width no prescaler 0.5 t cy + 20* ns with prescaler 10* ns 42 tt0p t0cki period t cy + 40 * n ns n = prescale value (1, 2, 4, ..., 256) * these parameters are characterized but not tested. ? data in "typ" column is at 5.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. 41 42 40 ra4/t0cki tmr0
1999 microchip technology inc. preliminary ds40300b-page 145 pic16f62x 18.0 device characterization information not available at this time.
pic16f62x ds40300b-page 146 preliminary 1999 microchip technology inc. notes:
1999 microchip technology inc. preliminary ds40300b-page 147 pic16f62x 19.0 packaging information 19.1 package marking information 20-lead ssop xxxxxxxxxx aabbcde xxxxxxxxxx 18-lead soic (.300") xxxxxxxxxxxx aabbcde xxxxxxxxxxxx xxxxxxxxxxxx xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx aabbcde 18-lead pdip example -04i / 218 9951 cbp pic16f627 example -04i / s0218 9918 cdk pic16f627 pic16f627 -04i / p456 9923 cba example legend: mm...m microchip part number information xx...x customer specific information* aa year code (last 2 digits of calendar year) bb week code (week of january 1 is week 01) c facility code of the plant at which wafer is manufactured o = outside vendor c = 5 line s = 6 line h = 8 line d mask revision number e assembly code of the plant or country of origin in which part was assembled note : in the event the full microchip part number cannot be marked on one line, it will be carried over to the next line thus limiting the number of available characters for customer specific information. * standard otp marking consists of microchip part number, year code, week code, facility code, mask rev#, and assembly code. for otp marking beyond this, certain price adders apply. please check with your microchip sales office. for qtp devices, any special marking adders are included in qtp price.
pic16f62x ds40300b-page 148 preliminary 1999 microchip technology inc. package type: k04-007 18-lead plastic dual in-line (p) C 300 mil * controlling parameter. ? dimension b1 does not include dam-bar protrusions. dam-bar protrusions shall not exceed 0.003 (0.076 mm) per side or 0.006 (0.152 mm) more than dimension b1. ? dimensions d and e do not include mold flash or protrusions. mold flash or protrusions shall not exceed 0.010 (0.254 mm) per side or 0.020 (0.508 mm) more than dimensions d or e. units inches* millimeters dimension limits min nom max min nom max pcb row spacing 0.300 7.62 number of pins n 18 18 pitch p 0.100 2.54 lower lead width b 0.013 0.018 0.023 0.33 0.46 0.58 upper lead width b1 ? 0.055 0.060 0.065 1.40 1.52 1.65 shoulder radius r 0.000 0.005 0.010 0.00 0.13 0.25 lead thickness c 0.005 0.010 0.015 0.13 0.25 0.38 top to seating plane a 0.110 0.155 0.155 2.79 3.94 3.94 top of lead to seating plane a1 0.075 0.095 0.115 1.91 2.41 2.92 base to seating plane a2 0.000 0.020 0.020 0.00 0.51 0.51 tip to seating plane l 0.125 0.130 0.135 3.18 3.30 3.43 package length d ? 0.890 0.895 0.900 22.61 22.73 22.86 molded package width e ? 0.245 0.255 0.265 6.22 6.48 6.73 radius to radius width e1 0.230 0.250 0.270 5.84 6.35 6.86 overall row spacing eb 0.310 0.349 0.387 7.87 8.85 9.83 mold draft angle top a 5 10 15 5 10 15 mold draft angle bottom b 5 10 15 5 10 15 r n 2 1 d e c eb b e1 a p a1 l b1 b a a2
1999 microchip technology inc. preliminary ds40300b-page 149 pic16f62x package type: k04-051 18-lead plastic small outline (so) C wide, 300 mil 0.014 0.009 0.010 0.011 0.005 0.005 0.010 0.394 0.292 0.450 0.004 0.048 0.093 min n number of pins mold draft angle bottom mold draft angle top lower lead width chamfer distance outside dimension molded package width molded package length overall pack. height lead thickness radius centerline foot angle foot length gull wing radius shoulder radius standoff shoulder height b a r2 r1 e1 a2 a1 x f b ? c l1 l e ? d ? a dimension limits pitch units p 18 18 0 0 12 12 15 15 4 0.020 0 0.017 0.011 0.015 0.016 0.005 0.005 0.407 0.296 0.456 0.008 0.058 0.099 0.029 0.019 0.012 0.020 0.021 0.010 0.010 8 0.419 0.299 0.462 0.011 0.068 0.104 0 0 12 12 15 15 0.42 0.27 0.38 0.41 0.13 0.13 0.50 10.33 7.51 11.58 0.19 1.47 2.50 0.25 0 0.36 0.23 0.25 0.28 0.13 0.13 10.01 7.42 11.43 0.10 1.22 2.36 0.74 48 0.48 0.30 0.51 0.53 0.25 0.25 10.64 7.59 11.73 0.28 1.73 2.64 inches* 0.050 nom max 1.27 millimeters min nom max n 2 1 r2 r1 l1 l b c f x 45 d p b e e1 a a1 a2 a * controlling parameter. ? dimension b does not include dam-bar protrusions. dam-bar protrusions shall not exceed 0.003 (0.076 mm) per side or 0.006 (0.152 mm) more than dimension b. ? dimensions d and e do not include mold flash or protrusions. mold flash or protrusions shall not exceed 0.010 (0.254 mm) per side or 0.020 (0.508 mm) more than dimensions d or e.
pic16f62x ds40300b-page 150 preliminary 1999 microchip technology inc. package type: k04-072 20-lead plastic shrink small outline (ss) C 5.30 mm min p pitch mold draft angle bottom mold draft angle top lower lead width radius centerline gull wing radius shoulder radius outside dimension molded package width molded package length shoulder height overall pack. height lead thickness foot angle foot length standoff number of pins b a c f a2 a1 a n e1 b ? l1 r2 l r1 e ? d ? dimension limits units 0.65 0.026 8 0 0 5 510 10 0.012 0.007 0.005 0.020 0.005 0.005 0.306 0.208 0.283 0.005 0.036 0.073 20 0.301 0 0.010 0.005 0.000 0.015 0.005 0.005 0.205 0.278 0.002 0.026 0.068 0.311 0.015 0.009 0.010 0.025 0.010 0.010 48 0.212 0.289 0.008 0.046 0.078 0 05 510 10 7.65 0.25 0.13 0.00 0.38 0.13 0.13 0 5.20 7.07 0.05 0.66 1.73 7.90 7.78 4 0.32 0.18 0.13 0.13 0.51 0.13 0.38 0.22 0.25 0.25 0.64 0.25 5.29 7.20 0.13 20 1.86 0.91 5.38 7.33 0.21 1.99 1.17 nom inches max nom millimeters* min max n 1 2 r1 r2 d p b e1 e l1 l c b f a a1 a a2 * controlling parameter. ? dimension b does not include dam-bar protrusions. dam-bar protrusions shall not exceed 0.003 (0.076 mm) per side or 0.006 (0.152 mm) more than dimension b. ? dimensions d and e do not include mold flash or protrusions. mold flash or protrusions shall not exceed 0.010 (0.254 mm) per side or 0.020 (0.508 mm) more than dimensions d or e.
1999 microchip technology inc. preliminary ds40300b-page 151 pic16f62x index a a/d special event trigger (ccp)....................................... 65 absolute maximum ratings .............................................. 131 addlw instruction ........................................................... 115 addwf instruction ........................................................... 115 andlw instruction ........................................................... 115 andwf instruction ........................................................... 115 architectural overview .......................................................... 9 assembler mpasm assembler................................................... 125 b baud rate error .................................................................. 73 baud rate formula ............................................................. 73 baud rates asynchronous mode ................................................... 74 synchronous mode ..................................................... 74 bcf instruction ................................................................. 116 block diagram timer0....................................................................... 45 tmr0/wdt prescaler .......................................... 48 block diagrams comparator i/o operating modes............................... 58 comparator output ..................................................... 60 ra3:ra0 and ra5 port pins ...................................... 35 timer1......................................................................... 51 timer2......................................................................... 54 usart receive.......................................................... 80 usart transmit......................................................... 78 brgh bit............................................................................. 73 brown-out detect (bod) .................................................. 101 bsf instruction ................................................................. 116 btfsc instruction............................................................. 116 btfss instruction ............................................................. 117 c call instruction ............................................................... 117 capture (ccp module) ....................................................... 64 block diagram............................................................. 64 ccp pin configuration................................................ 64 ccpr1h:ccpr1l registers...................................... 64 changing between capture prescalers...................... 64 software interrupt ....................................................... 64 timer1 mode selection ............................................... 64 capture/compare/pwm (ccp)........................................... 63 ccp1 .......................................................................... 63 ccp1con register............................................ 63 ccpr1h register............................................... 63 ccpr1l register ............................................... 63 ccp2 .......................................................................... 63 timer resources......................................................... 63 ccp1con register ............................................................ 63 ccp1m3:ccp1m0 bits............................................... 63 ccp1x:ccp1y bits .................................................... 63 ccp2con register ccp2m3:ccp2m0 bits............................................... 63 ccp2x:ccp2y bits .................................................... 63 clocking scheme/instruction cycle .................................... 12 clrf instruction ............................................................... 117 clrw instruction .............................................................. 117 clrwdt instruction ......................................................... 118 cmcon register ................................................................ 57 code protection ................................................................ 112 comf instruction .............................................................. 118 comparator configuration................................................... 58 comparator interrupts......................................................... 61 comparator module ............................................................ 57 comparator operation ........................................................ 59 comparator reference ....................................................... 59 compare (ccp module) ..................................................... 65 block diagram ............................................................ 65 ccp pin configuration ............................................... 65 ccpr1h:ccpr1l registers ..................................... 65 software interrupt ....................................................... 65 special event trigger ................................................. 65 timer1 mode selection............................................... 65 configuration bits ............................................................... 96 configuring the voltage reference..................................... 69 crystal operation................................................................ 97 d data .................................................................................. 93 data .................................................................................... 93 data eeprom memory...................................................... 91 eecon1 register ...................................................... 91 eecon2 register ...................................................... 91 data memory organization................................................. 13 decf instruction .............................................................. 118 decfsz instruction.......................................................... 118 development support ....................................................... 125 e eecon1 ............................................................................. 92 errata .................................................................................... 3 external crystal oscillator circuit ....................................... 98 g general purpose register file............................................ 13 goto instruction.............................................................. 119 i i/o ports ............................................................................. 27 i/o programming considerations ....................................... 44 id locations...................................................................... 112 incf instruction................................................................ 119 incfsz instruction ........................................................... 119 in-circuit serial programming........................................... 112 indirect addressing, indf and fsr registers ................... 26 instruction flow/pipelining .................................................. 12 instruction set addlw..................................................................... 115 addwf .................................................................... 115 andlw..................................................................... 115 andwf .................................................................... 115 bcf .......................................................................... 116 bsf........................................................................... 116 btfsc...................................................................... 116 btfss ...................................................................... 117 call......................................................................... 117 clrf ........................................................................ 117 clrw ....................................................................... 117 clrwdt .................................................................. 118 comf ....................................................................... 118 decf........................................................................ 118 decfsz ................................................................... 118 goto ....................................................................... 119 incf ......................................................................... 119 incfsz..................................................................... 119 iorlw...................................................................... 119 iorwf...................................................................... 120 movf ....................................................................... 120 movlw .................................................................... 120 movwf.................................................................... 120
pic16f62x ds40300b-page 152 preliminary 1999 microchip technology inc. nop .......................................................................... 121 option .................................................................... 121 retfie ..................................................................... 121 retlw ..................................................................... 121 return ................................................................... 122 rlf ........................................................................... 122 rrf........................................................................... 122 sleep ...................................................................... 122 sublw ..................................................................... 123 subwf ..................................................................... 123 swapf ..................................................................... 124 tris.......................................................................... 124 xorlw ..................................................................... 124 xorwf..................................................................... 124 instruction set summary................................................... 113 int interrupt ...................................................................... 108 intcon register ................................................................ 21 interrupt sources capture complete (ccp)............................................ 64 compare complete (ccp).......................................... 65 tmr2 to pr2 match (pwm) ....................................... 66 interrupts ........................................................................... 107 interrupts, enable bits ccp1 enable (ccp1ie bit)......................................... 64 interrupts, flag bits ccp1 flag (ccp1if bit) ....................................... 64, 65 iorlw instruction............................................................. 119 iorwf instruction............................................................. 120 k keeloq evaluation and programming tools.................. 128 m memory organization data eeprom memory.............................................. 91 movf instruction .............................................................. 120 movlw instruction ........................................................... 120 movwf instruction........................................................... 120 mplab integrated development environment software .. 125 n nop instruction................................................................. 121 o option instruction........................................................... 121 option register ................................................................ 20 oscillator configurations ..................................................... 97 oscillator start-up timer (ost) ........................................ 101 output of tmr2................................................................... 54 p package marking information ........................................... 147 packaging information ...................................................... 147 pcl and pclath ............................................................... 25 pcon register ................................................................... 24 picdem-1 low-cost picmicro demo board.................... 127 picdem-2 low-cost pic16cxx demo board ................. 127 picdem-3 low-cost pic16cxxx demo board............... 127 picstart plus entry level development system ....... 127 pie1 register ...................................................................... 22 pin functions rc6/tx/ck ........................................................... 71C88 rc7/rx/dt ........................................................... 71C88 pinout description ............................................................... 11 pir1 register...................................................................... 23 port rb interrupt ............................................................... 108 porta................................................................................ 27 portb................................................................................ 34 power control/status register (pcon) ............................ 102 power-down mode (sleep) ............................................ 111 power-on reset (por) .................................................... 101 power-up timer (pwrt) .................................................. 101 pr2 register ...................................................................... 54 prescaler............................................................................. 48 prescaler, capture.............................................................. 64 prescaler, timer2 ............................................................... 66 pro mate ii universal programmer ............................ 127 program memory organization........................................... 13 protection .................................................................... 93 pwm (ccp module) ........................................................... 66 block diagram ............................................................ 66 ccpr1h:ccpr1l registers...................................... 66 duty cycle .................................................................. 66 example frequencies/resolutions ............................. 67 output diagram .......................................................... 66 period ......................................................................... 66 set-up for pwm operation......................................... 67 tmr2 to pr2 match ................................................... 66 q q-clock............................................................................... 66 quick-turnaround-production (qtp) devices...................... 7 r rc oscillator....................................................................... 98 reading ........................................................................... 93 registers maps pic16c76 ........................................................... 14 pic16c77 ........................................................... 14 rcsta diagram .............................................................. 72 reset .................................................................................. 99 retfie instruction ........................................................... 121 retlw instruction............................................................ 121 return instruction ......................................................... 122 rlf instruction ................................................................. 122 rrf instruction................................................................. 122 s seeval evaluation and programming system............. 128 serialized quick-turnaround-production (sqtp) devices.................................................................... 7 sleep instruction............................................................. 122 software simulator (mplab-sim) .................................... 126 special ................................................................................ 99 special features of the cpu .............................................. 95 special function registers ................................................. 15 stack................................................................................... 25 status register ................................................................... 19 sublw instruction ........................................................... 123 subwf instruction ........................................................... 123 swapf instruction ........................................................... 124 t t1ckps0 bit ....................................................................... 50 t1ckps1 bit ....................................................................... 50 t1con register ................................................................. 50 t1oscen bit ...................................................................... 50 t1sync bit......................................................................... 50 t2ckps0 bit ....................................................................... 55 t2ckps1 bit ....................................................................... 55 t2con register ................................................................. 55
1999 microchip technology inc. preliminary ds40300b-page 153 pic16f62x timer0 timer0....................................................................... 45 timer0 (tmr0) interrupt ........................................... 45 timer0 (tmr0) module............................................. 45 tmr0 with external clock........................................... 47 timer1 special event trigger (ccp)....................................... 65 switching prescaler assignment................................. 49 timer2 pr2 register............................................................... 66 tmr2 to pr2 match interrupt ..................................... 66 timers timer1 asynchronous counter mode ............................. 52 block diagram .................................................... 51 capacitor selection............................................. 52 external clock input............................................ 51 external clock input timing ................................ 52 operation in timer mode .................................... 51 oscillator ............................................................. 52 prescaler....................................................... 51, 53 resetting of timer1 registers ............................ 53 resetting timer1 using a ccp trigger output ... 53 synchronized counter mode .............................. 51 t1con................................................................ 50 tmr1h ............................................................... 52 tmr1l ................................................................ 52 timer2 block diagram .................................................... 54 module ................................................................ 54 postscaler ........................................................... 54 prescaler............................................................. 54 t2con................................................................ 55 timing diagrams timer0....................................................................... 142 timer1....................................................................... 142 usart asynchronous master transmission.............. 79 usart rx pin sampling...................................... 76, 77 usart synchronous reception................................. 87 usart synchronous transmission ........................... 85 usart, asynchronous reception.............................. 81 timing diagrams and specifications................................. 139 tmr0 interrupt .................................................................. 108 tmr1cs bit ........................................................................ 50 tmr1on bit ........................................................................ 50 tmr2on bit ........................................................................ 55 toutps0 bit....................................................................... 55 toutps1 bit....................................................................... 55 toutps2 bit....................................................................... 55 toutps3 bit....................................................................... 55 tris instruction ................................................................ 124 trisa ................................................................................. 27 trisb ................................................................................. 34 txsta register .................................................................. 71 u universal synchronous asynchronous receiver transmitter (usart) .......................................................... 71 asynchronous receiver setting up reception .......................................... 83 timing diagram .................................................. 81 asynchronous receiver mode block diagram .................................................... 83 section ................................................................ 83 usart asynchronous mode................................................... 78 asynchronous receiver.............................................. 80 asynchronous reception............................................ 82 asynchronous transmission ...................................... 79 asynchronous transmitter.......................................... 78 baud rate generator (brg) ...................................... 73 sampling..................................................................... 76 synchronous master mode......................................... 84 synchronous master reception ................................. 86 synchronous master transmission ............................ 84 synchronous slave mode........................................... 88 synchronous slave reception ................................... 88 synchronous slave transmit...................................... 88 transmit block diagram ............................................. 78 v voltage reference module ................................................. 69 vrcon register ................................................................ 69 w watchdog timer (wdt).................................................... 109 write ................................................................................ 93 writing ............................................................................ 93 www, on-line support ....................................................... 3 x xorlw instruction ........................................................... 124 xorwf instruction........................................................... 124
pic16f62x ds40300b-page 154 preliminary 1999 microchip technology inc.
1999 microchip technology inc. preliminary ds40300b-page 155 pic16f62x systems information and upgrade hot line the systems information and upgrade line provides system users a listing of the latest versions of all of microchip's development systems software products. plus, this line provides information on how customers can receive any currently available upgrade kits.the hot line numbers are: 1-800-755-2345 for u.s. and most of canada, and 1-602-786-7302 for the rest of the world. trademarks: the microchip name, logo, pic, picmicro, picstart, picmaster and pro mate are registered trademarks of microchip technology incorporated in the u.s.a. and other countries. flex rom, mplab and fuzzy- lab are trademarks and sqtp is a service mark of micro- chip in the u.s.a. all other trademarks mentioned herein are the property of their respective companies. on-line support microchip provides on-line support on the microchip world wide web (www) site. the web site is used by microchip as a means to make files and information easily available to customers. to view the site, the user must have access to the internet and a web browser, such as netscape or microsoft explorer. files are also available for ftp download from our ftp site. connecting to the microchip internet web site the microchip web site is available by using your favorite internet browser to attach to: www.microchip.com the file transfer site is available by using an ftp ser- vice to connect to: ftp://ftp.microchip.com the web site and file transfer site provide a variety of services. users may download files for the latest development tools, data sheets, application notes, user's guides, articles and sample programs. a vari- ety of microchip specific business information is also available, including listings of microchip sales offices, distributors and factory representatives. other data available for consideration is: ? latest microchip press releases ? technical support section with frequently asked questions ? design tips ? device errata ? job postings ? microchip consultant program member listing ? links to other useful web sites related to microchip products ? conferences for products, development sys- tems, technical information and more ? listing of seminars and events 981103
pic16f62x ds40300b-page 156 preliminary 1999 microchip technology inc. reader response it is our intention to provide you with the best documentation possible to ensure successful use of your microchip prod- uct. if you wish to provide your comments on organization, clarity, subject matter, and ways in which our documentation can better serve you, please fax your comments to the technical publications manager at (602) 786-7578. please list the following information, and use this outline to provide us with your comments about this data sheet. 1. what are the best features of this document? 2. how does this document meet your hardware and software development needs? 3. do you find the organization of this data sheet easy to follow? if not, why? 4. what additions to the data sheet do you think would enhance the structure and subject? 5. what deletions from the data sheet could be made without affecting the overall usefulness? 6. is there any incorrect or misleading information (what and where)? 7. how would you improve this document? 8. how would you improve our software, systems, and silicon products? to : technical publications manager re: reader response total pages sent from: name company address city / state / zip / country telephone: (_______) _________ - _________ application (optional): would you like a reply? y n device: literature number: questions: fax: (______) _________ - _________ ds40300b pic16f62x
1999 microchip technology inc. preliminary ds40300b-page 157 pic16f62x pic16f62x product identification system to order or to obtain information, e.g., on pricing or delivery, please use the listed part numbers, and refer to the factory o r the listed sales offices. sales and support data sheets products supported by a preliminary data sheet may have an errata sheet describing minor operational differences and recom- mended workarounds. to determine if an errata sheet exists for a particular device, please contact one of the following: 1. your local microchip sales office 2. the microchip corporate literature center u.s. fax: (602) 786-7277 3. the microchip worldwide site (www.microchip.com) please specify which device, revision of silicon and data sheet (include literature #) you are using. new customer notification system register on our web site (www.microchip.com/cn) to receive the most current information on our products. pattern: 3-digit pattern code for qtp (blank otherwise) package: p=pdip so = soic (gull wing, 300 mil body) ss = ssop (209 mil) temperature -=0 c to +70c range: i = C40c to +85c e = C40c to +125c frequency 04 = 200khz (lp osc) range: 04 = 4 mhz (xt and er osc) 20 = 20 mhz (hs osc) device: pic16f62x :v dd range 3.0v to 5.5v pic16f62xt:v dd range 3.0v to 5.5v (tape and reel) pic16lf62x:v dd range 2.0v to 5.5v pic16lf62xt:v dd range 2.0v to 5.5v (tape and reel) examples: g) pic16f627 - 04/p 301 = commercial temp., pdip pack- age, 4 mhz, normal v dd limits, qtp pattern #301. h) pic16lf627- 04i/so = industrial temp., soic pack- age, 200khz, extended v dd limits. part no. -xx x /xx xxx
pic16f62x ds40300b-page 158 1999 microchip technology inc. notes:
1999 microchip technology inc. preliminary ds40300b-page 159 pic16f62x notes:
? 2002 microchip technology inc. information contained in this publication regarding device applications and the like is intended through suggestion only and may be superseded by updates. it is your responsibility to ensure that your application meets with your specifications. no representation or warranty is given and no liability is assumed by microchip technology incorporated with respect to the accuracy or use of such information, or infringement of patents or other intellectual property rights arising from such use or otherwise. use of microchip?s products as critical com- ponents in life support systems is not authorized except with express written approval by microchip. no licenses are con- veyed, implicitly or otherwise, under any intellectual property rights. trademarks the microchip name and logo, the microchip logo, filterlab, k ee l oq , microid, mplab, pic, picmicro, picmaster, picstart, pro mate, seeval and the embedded control solutions company are registered trademarks of microchip tech- nology incorporated in the u.s.a. and other countries. dspic, economonitor, fansense, flexrom, fuzzylab, in-circuit serial programming, icsp, icepic, microport, migratable memory, mpasm, mplib, mplink, mpsim, mxdev, picc, picdem, picdem.net, rfpic, select mode and total endurance are trademarks of microchip technology incorporated in the u.s.a. serialized quick turn programming (sqtp) is a service mark of microchip technology incorporated in the u.s.a. all other trademarks mentioned herein are property of their respective companies. ? 2002, microchip technology incorporated, printed in the u.s.a., all rights reserved. printed on recycled paper. microchip received qs-9000 quality system certification for its worldwide headquarters, design and wafer fabrication facilities in chandler and tempe, arizona in july 1999. the company?s quality system processes and procedures are qs-9000 compliant for its picmicro ? 8-bit mcus, k ee l oq ? code hopping devices, serial eeproms and microperipheral products. in addition, microchip ? s quality system for the design and manufacture of development systems is iso 9001 certified. note the following details of the code protection feature on picmicro ? mcus.  the picmicro family meets the specifications contained in the microchip data sheet.  microchip believes that its family of picmicro microcontrollers is one of the most secure products of its kind on the market to day, when used in the intended manner and under normal conditions.  there are dishonest and possibly illegal methods used to breach the code protection feature. all of these methods, to our knowl - edge, require using the picmicro microcontroller in a manner outside the operating specifications contained in the data sheet. the person doing so may be engaged in theft of intellectual property.  microchip is willing to work with the customer who is concerned about the integrity of their code.  neither microchip nor any other semiconductor manufacturer can guarantee the security of their code. code protection does not mean that we are guaranteeing the product as ? unbreakable ? .  code protection is constantly evolving. we at microchip are committed to continuously improving the code protection features of our product. if you have any further questions about this matter, please contact the local sales office nearest to you.
? 2002 microchip technology inc. m americas corporate office 2355 west chandler blvd. chandler, az 85224-6199 tel: 480-792-7200 fax: 480-792-7277 technical support: 480-792-7627 web address: http://www.microchip.com rocky mountain 2355 west chandler blvd. chandler, az 85224-6199 tel: 480-792-7966 fax: 480-792-7456 atlanta 500 sugar mill road, suite 200b atlanta, ga 30350 tel: 770-640-0034 fax: 770-640-0307 boston 2 lan drive, suite 120 westford, ma 01886 tel: 978-692-3848 fax: 978-692-3821 chicago 333 pierce road, suite 180 itasca, il 60143 tel: 630-285-0071 fax: 630-285-0075 dallas 4570 westgrove drive, suite 160 addison, tx 75001 tel: 972-818-7423 fax: 972-818-2924 detroit tri-atria office building 32255 northwestern highway, suite 190 farmington hills, mi 48334 tel: 248-538-2250 fax: 248-538-2260 kokomo 2767 s. albright road kokomo, indiana 46902 tel: 765-864-8360 fax: 765-864-8387 los angeles 18201 von karman, suite 1090 irvine, ca 92612 tel: 949-263-1888 fax: 949-263-1338 new york 150 motor parkway, suite 202 hauppauge, ny 11788 tel: 631-273-5305 fax: 631-273-5335 san jose microchip technology inc. 2107 north first street, suite 590 san jose, ca 95131 tel: 408-436-7950 fax: 408-436-7955 toronto 6285 northam drive, suite 108 mississauga, ontario l4v 1x5, canada tel: 905-673-0699 fax: 905-673-6509 asia/pacific australia microchip technology australia pty ltd suite 22, 41 rawson street epping 2121, nsw australia tel: 61-2-9868-6733 fax: 61-2-9868-6755 china - beijing microchip technology consulting (shanghai) co., ltd., beijing liaison office unit 915 bei hai wan tai bldg. no. 6 chaoyangmen beidajie beijing, 100027, no. china tel: 86-10-85282100 fax: 86-10-85282104 china - chengdu microchip technology consulting (shanghai) co., ltd., chengdu liaison office rm. 2401, 24th floor, ming xing financial tower no. 88 tidu street chengdu 610016, china tel: 86-28-6766200 fax: 86-28-6766599 china - fuzhou microchip technology consulting (shanghai) co., ltd., fuzhou liaison office unit 28f, world trade plaza no. 71 wusi road fuzhou 350001, china tel: 86-591-7503506 fax: 86-591-7503521 china - shanghai microchip technology consulting (shanghai) co., ltd. room 701, bldg. b far east international plaza no. 317 xian xia road shanghai, 200051 tel: 86-21-6275-5700 fax: 86-21-6275-5060 china - shenzhen microchip technology consulting (shanghai) co., ltd., shenzhen liaison office rm. 1315, 13/f, shenzhen kerry centre, renminnan lu shenzhen 518001, china tel: 86-755-2350361 fax: 86-755-2366086 hong kong microchip technology hongkong ltd. unit 901-6, tower 2, metroplaza 223 hing fong road kwai fong, n.t., hong kong tel: 852-2401-1200 fax: 852-2401-3431 india microchip technology inc. india liaison office divyasree chambers 1 floor, wing a (a3/a4) no. 11, o?shaugnessey road bangalore, 560 025, india tel: 91-80-2290061 fax: 91-80-2290062 japan microchip technology japan k.k. benex s-1 6f 3-18-20, shinyokohama kohoku-ku, yokohama-shi kanagawa, 222-0033, japan tel: 81-45-471- 6166 fax: 81-45-471-6122 korea microchip technology korea 168-1, youngbo bldg. 3 floor samsung-dong, kangnam-ku seoul, korea 135-882 tel: 82-2-554-7200 fax: 82-2-558-5934 singapore microchip technology singapore pte ltd. 200 middle road #07-02 prime centre singapore, 188980 tel: 65-334-8870 fax: 65-334-8850 taiwan microchip technology taiwan 11f-3, no. 207 tung hua north road taipei, 105, taiwan tel: 886-2-2717-7175 fax: 886-2-2545-0139 europe denmark microchip technology nordic aps regus business centre lautrup hoj 1-3 ballerup dk-2750 denmark tel: 45 4420 9895 fax: 45 4420 9910 france microchip technology sarl parc d?activite du moulin de massy 43 rue du saule trapu batiment a - ler etage 91300 massy, france tel: 33-1-69-53-63-20 fax: 33-1-69-30-90-79 germany microchip technology gmbh gustav-heinemann ring 125 d-81739 munich, germany tel: 49-89-627-144 0 fax: 49-89-627-144-44 italy microchip technology srl centro direzionale colleoni palazzo taurus 1 v. le colleoni 1 20041 agrate brianza milan, italy tel: 39-039-65791-1 fax: 39-039-6899883 united kingdom arizona microchip technology ltd. 505 eskdale road winnersh triangle wokingham berkshire, england rg41 5tu tel: 44 118 921 5869 fax: 44-118 921-5820 01/18/02 w orldwide s ales and s ervice


▲Up To Search▲   

 
Price & Availability of PIC16F628T-04SO025

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X